Package org.broad.igv.feature.genome

Examples of org.broad.igv.feature.genome.Genome


        String testFile = "path-to-test-file.bb";
        String chr = "chr7";
        int start = 26133475;
        int end = 27333475;
        Genome genome = null;

        BBFileReader reader = new BBFileReader(testFile);
        MethylDataSource source = new BBMethylDataSource(reader, BBMethylDataSource.Type.ZILLER, genome);
        Iterator<MethylScore> iter = source.query(chr, start, end);
        List<MethylScore> nonCachedScores = new ArrayList<MethylScore>();
View Full Code Here


     * @param posChromos Chromosomes for which all values are positive
     * @param emptyChromos Chromosomes which have no data
     * @throws Exception
     */
    public void tstCHR_ALL(String genPath, String wigPath, String tdfPath, boolean expHaveChrAll, String[] posChromos, String[] emptyChromos) throws Exception{
        Genome genome = null;
        try {
            genome = GenomeManager.getInstance().loadGenome(genPath, null);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Assume.assumeTrue(genome != null);


        WiggleDataset ds = (new WiggleParser(new ResourceLocator(wigPath), genome)).parse();
        DatasetDataSource wigSource = new DatasetDataSource(wigPath, ds, genome);


        TDFReader tdfReader = TDFReader.getReader(tdfPath);
        TDFDataSource tdfSource = new TDFDataSource(tdfReader, 0, tdfPath, genome);

        //We can't test for exact equality, so we just look for errors
        List<LocusScore> wigScores = wigSource.getSummaryScoresForRange(Globals.CHR_ALL, -1, -1, 0);
        List<LocusScore> tdfScores = tdfSource.getSummaryScoresForRange(Globals.CHR_ALL, -1, -1, 0);

        assertEquals(expHaveChrAll, tdfSource.isChrOrderValid());

        if(!expHaveChrAll){
            //Ideally we would recalculate the data, but returning nothing
            //is preferable to returning incorrect data
            if(tdfScores.size() == 0){
                return;
            }
        }


        //TODO This test could be more efficient, and we could be more precise
        //about chromosome boundaries
        int posChecked = 0;
        for(String chromo: posChromos){
            //We allow a little slop around chromo boundaries
            long range = genome.getChromosome(chromo).getLength() / 1000;
            long fudge = Math.max(500, range / 100);
            range -= 2 * fudge;

            long cMin = genome.getCumulativeOffset(chromo) / 1000 + fudge;
            long cMax = cMin + range;

            for(int ii= 0; ii < wigScores.size(); ii++){
                LocusScore wLocus = wigScores.get(ii);
                if(wLocus.getStart() >= cMin && wLocus.getEnd() <= cMax){
                    float wScore = wigScores.get(ii).getScore();
                    //Just checking our assumption
                    assert wScore > 0;
                }

                LocusScore tLocus = tdfScores.get(ii);
                if(overlaps(cMin, cMax, tLocus)){
                    assertTrue("Found negative value in " + chromo + " at " + tLocus.getStart(), tLocus.getScore() >= 0);
                    posChecked++;
                }
            }

        }

        //assertTrue(posChecked > 0);
        System.out.println("# Checked for positive values: " + posChecked);

        for(String chromo: emptyChromos){
            long range = genome.getChromosome(chromo).getLength() / 1000;

            long fudge = Math.max(600, range / 100);
            range -= 2 * fudge;

            long cMin = (genome.getCumulativeOffset(chromo) / 1000) + fudge;
            long cMax = cMin + range;

            for(LocusScore wLocus: wigScores){
                //Just checking our assumption
                assert wLocus.getStart() < cMin || wLocus.getEnd() > cMax;
View Full Code Here

        AsciiLineReader reader = null;

        String nextLine = null;
        int rowCounter = 0;
        try {
            Genome genome = GenomeManager.getInstance().getCurrentGenome();

            reader = ParsingUtils.openAsciiReader(locator);

            // Parse header
            reader.readLine();
            rowCounter++;

            // Parse data
            // parameters to track chromosome breaks. Used in wholeGenome case.
            GisticTrack track = new GisticTrack(locator);
            track.setName(locator.getTrackName());
            List<GisticScore> scores = new ArrayList();

            nextLine = reader.readLine();
            rowCounter++;

            while ((nextLine != null) && (nextLine.length() > 0)) {
                String[] tokens = nextLine.split("\t");

                GisticScore.Type type = getType(tokens[0].trim());
                String chr = genome.getChromosomeAlias(tokens[1].trim());

                int start = -1;
                try {
                    start = Integer.parseInt(tokens[2]);
                }
View Full Code Here

                    final ProgressBar.ProgressDialog progressDialog = ProgressBar.showProgressDialog(IGV.getMainFrame(), "Loading Genome...", monitor, false);

                    try {
                        monitor.fireProgressChange(50);

                        Genome genome;

                        igv.resetSession(null);
                        genome = igv.getGenomeManager().loadGenome(genomeListItem.getLocation(), null);

                        updateChromosFromGenome(genome);
                        monitor.fireProgressChange(25);

                        genomeComboBox.setSelectedItem(genomeListItem);

                        monitor.fireProgressChange(25);

                        FrameManager.getDefaultFrame().setChromosomeName(genome.getHomeChromosome(), true);
                        IGV.getInstance().doRefresh();

                    } catch (GenomeServerException e) {
                        log.error("Error loading genome: " + genomeListItem.getLocation(), e);
                        JOptionPane.showMessageDialog(
View Full Code Here

        }
    }

    void updateChromosomeDropdown() {

        final Genome genome = GenomeManager.getInstance().getCurrentGenome();
        if (genome == null) return;

        List<String> tmp = new ArrayList<String>(genome.getAllChromosomeNames().size());
        tmp.addAll(genome.getAllChromosomeNames());
        if (tmp.size() > 1) {
            String homeChr = genome.getHomeChromosome();
            if (homeChr.equals(Globals.CHR_ALL)) {
                tmp.add(0, Globals.CHR_ALL);
            }
        }

        Graphics2D graphics2D = (Graphics2D) chromosomeComboBox.getGraphics();
        Font font = chromosomeComboBox.getFont();
        FontMetrics fontMetrics = chromosomeComboBox.getFontMetrics(font);

        int w = DEFAULT_CHROMOSOME_DROPDOWN_WIDTH;
        for (String chromosomeName : tmp) {
            Rectangle2D textBounds = fontMetrics.getStringBounds(chromosomeName, graphics2D);
            if (textBounds != null) {
                int width = textBounds.getBounds().width + 50;

                // int width = chromosomeName.length()*fontSize-(fontSize*4);  // TODO Hack figure out whats's wrong with previous line
                if (width > w) {
                    w = width;
                }
            }
        }

        Object[] chomosomeNames = tmp.toArray();
        final DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(chomosomeNames);
        final int dropdownWidth = w;

        chromosomeComboBox.setModel(defaultModel);
        chromosomeComboBox.setSelectedItem(genome.getHomeChromosome());

        UIUtilities.invokeOnEventThread(new Runnable() {

            public void run() {
                adjustChromosomeDropdownWidth(dropdownWidth);
View Full Code Here

        scrollPane.setMaximumSize(size);
        scrollPane.revalidate();
    }

    private void homeButtonActionPerformed(java.awt.event.ActionEvent evt) {
        Genome genome = GenomeManager.getInstance().getCurrentGenome();
        if (FrameManager.isGeneListMode()) {
            IGV.getInstance().setGeneList(null);
        }
        if (genome != null) {
            String chrName = genome.getHomeChromosome();
            if (chrName != null && !chrName.equals(chromosomeComboBox.getSelectedItem())) {
                ViewChange.ChromosomeChangeCause cause = new ViewChange.ChromosomeChangeCause(evt.getSource(), chrName);
                cause.setRecordHistory(true);
                getDefaultReferenceFrame().getEventBus().post(cause);
            }
View Full Code Here

        this.calculateMaxZoom();
    }


    private void init(FeatureTrack geneTrack) {
        Genome genome = GenomeManager.getInstance().getCurrentGenome();
        for (Chromosome chromosome : genome.getChromosomes()) {
            String chr = chromosome.getName();
            List<Feature> features = geneTrack.getFeatures(chr, 0, chromosome.getLength());
            if (features != null && features.size() > 0) {
                createExomeBlockData(chr, features);
            }
View Full Code Here

                }
                finally {
                    Runnable runnable = new Runnable() {
                        public void run() {
                            Genome genome = GenomeManager.getInstance().getCurrentGenome();
                            String chr = genome == null ? variant.chr : genome.getChromosomeAlias(variant.chr);
                            String locus = chr + ":" + variant.position;
                            IGV.getInstance().goToLocus(locus);
                            VariantListNavigator.this.setCursor(Cursor.getDefaultCursor());
                            VariantListNavigator.this.variantList.setEnabled(true);
                        }
View Full Code Here

        return records;
    }

    public static void doBlatQuery(final String chr, final int start, final int end) {

        Genome genome = GenomeManager.getInstance().getCurrentGenome();
        final byte[] seqBytes = genome.getSequence(chr, start, end);
        String userSeq = new String(seqBytes);

        doBlatQuery(userSeq);
    }
View Full Code Here

            }

            public void run() {
                try {

                    Genome genome = IGV.hasInstance() ? GenomeManager.getInstance().getCurrentGenome() : null;
                    PSLCodec codec = new PSLCodec(genome, true);

                    // TODO -- something better than this!
                    String db = genome.getId();
                    String species = genome.getSpecies();
                    if (species == null) species = genome.getDisplayName();

                    List<String> tokensList = blat(species, db, userSeq);

                    // Convert tokens to features
                    List<PSLRecord> features = new ArrayList<PSLRecord>(tokensList.size());
View Full Code Here

TOP

Related Classes of org.broad.igv.feature.genome.Genome

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.