Package org.broad.igv.feature.genome

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


        int[] starts = new int[nBins];
        int[] ends = new int[nBins];
        float[] values = new float[nBins];
        Arrays.fill(values, 0);

        Genome currentGenome = GenomeManager.getInstance().getCurrentGenome();
        double step = ((double) currentGenome.getNominalLength() / 1000) / nBins;
        for (int i = 0; i < nBins; i++) {
            starts[i] = (int) (i * step);
            ends[i] = (int) ((i + 1) * step);
        }


        for (String chr : currentGenome.getLongChromosomeNames()) {
            List<Feature> features = featureMap.get(chr);
            if (features != null) {
                long offset = currentGenome.getCumulativeOffset(chr);
                for (Feature f : features) {
                    int genStart = (int) ((offset + f.getStart()) / 1000);
                    int genEnd = (int) ((offset + f.getEnd()) / 1000);
                    int binStart = (int) (genStart / step);
                    int binEnd = (int) (genEnd / step);
View Full Code Here



    @Override
    public void finish() {

        Genome genome = GenomeManager.getInstance().getCurrentGenome();
        for (AlignmentBlock block : alignmentBlocks) {
            block.reduce(genome);
        }
    }
View Full Code Here

        final List<String> errors = new ArrayList<String>();
        final HashMap<String, List<Track>> loadedTracks = new HashMap();
        List<ResourceLocator> aSync = new ArrayList();

        // UCSC sessions do not have means to set genome, or if they do we don't use it
        Genome genome = GenomeManager.getInstance().getCurrentGenome();
        if (genome != null) {
            IGV.getInstance().setGenomeTracks(genome.getGeneTrack());
        }

        while ((nextLine = reader.readLine()) != null) {
            ResourceLocator locator = null;
            try {
View Full Code Here

    public Ga4ghAlignment(JsonObject json) {

        String refName = json.get("referenceSequenceName").getAsString();

        Genome genome = GenomeManager.getInstance().getCurrentGenome();
        this.setChr(genome == null ? refName : genome.getChromosomeAlias(refName));

        // SAMRecord is 1 based inclusive.  IGV is 0 based exclusive.
        this.readName = json.get("name").getAsString();
        this.flags = json.get("flags").getAsInt();
        this.alignmentStart = json.get("position").getAsInt() - 1;
        this.start = this.alignmentStart;   // might be modified later for soft clipping
        this.mappingQuality = json.get("mappingQuality").getAsInt();
        this.inferredInsertSize = json.get("templateLength").getAsInt();

        this.readSequence = json.get("originalBases").getAsString();


        this.cigarString = json.get("cigar").getAsString();
        this.alignmentEnd = this.alignmentStart + getReferenceLength(cigarString);
        this.end = alignmentEnd;

        if (isPaired()) {
            String mateReferenceName = json.get("mateReferenceSequenceName").getAsString();
            String mateChr = genome == null ? mateReferenceName : genome.getChromosomeAlias(mateReferenceName);
            this.setMate(new ReadMate(mateChr,
                    json.get("matePosition").getAsInt() - 1,
                    (this.flags & MATE_STRAND_FLAG) != 0,
                    (this.flags & MATE_UNMAPPED_FLAG) != 0));
        }
View Full Code Here

                // Output files must have .igv extension
                if (!ofile.endsWith(".igv")) {
                    ofile = ofile + ".igv";
                }
                String genomeId = nonOptionArgs[3];
                Genome genome = loadGenome(genomeId);
                if (genome == null) {
                    throw new PreprocessingException("Genome could not be loaded: " + genomeId);
                }
                String probeFile = (String) parser.getOptionValue(probeFileOption, PROBE_FILE);
                doGCTtoIGV(typeString, ifile, new File(ofile), probeFile, maxRecords, tmpDirName, genome);
View Full Code Here

            wfString += wf.toString() + " ";
        }
        log.info(wfString);

        boolean isGCT = isGCT(typeString);
        Genome genome = loadGenome(genomeId);
        if (genome == null) {
            throw new PreprocessingException("Genome could not be loaded: " + genomeId);
        }
        File inputFileOrDir = new File(ifile);
View Full Code Here

        }
        log.info(wfString);
        log.info("Ext factor = " + extFactorValue);


        Genome genome = loadGenome(genomeId);
        if (genome == null) {
            throw new PreprocessingException("Genome could not be loaded: " + genomeId);
        }

        // Multiple files allowed for count command (a tdf and a wig)
        File tdfFile = null;
        File wigFile = null;
        boolean wigStdOut = false;
        String[] files = ofile.split(",");
       
        for(String fileTok: files){
            if (fileTok.endsWith("wig")) {
                wigFile = new File(fileTok);
            } else if (fileTok.endsWith("tdf")) {
                tdfFile = new File(fileTok);
            }else if (fileTok.equals(STDOUT_FILE_STR)){
                wigStdOut = true;
            }
        }

        if (tdfFile != null && !tdfFile.getName().endsWith(".tdf")) {
            tdfFile = new File(tdfFile.getAbsolutePath() + ".tdf");
        }

        try {

            Preprocessor p = new Preprocessor(tdfFile, genome, windowFunctions, -1, null);

            p.setSkipZeroes(true);

            CoverageCounter counter = new CoverageCounter(ifile, p, windowSizeValue, extFactorValue, wigFile,
                    genome, queryString, minMapQuality, countFlags);
            counter.setWriteStdOut(wigStdOut);
            counter.setPreExtFactor(preExtFactorValue);
            counter.setPosExtFactor(postExtFactorValue);

            String prefix = FilenameUtils.getName(ifile);
            String[] tracknames = counter.getTrackNames(prefix + " ");
            p.setTrackParameters(TrackType.COVERAGE, trackLine, tracknames);

            p.setSizeEstimate(((int) (genome.getNominalLength() / windowSizeValue)));

            counter.parse();

            p.finish();
View Full Code Here

            }
            throw new RuntimeException(e);
        }


        Genome genome = null// <= don't do chromosome conversion
        FeatureCodec codec = CodecFactory.getCodec(ifile, genome);
        if (codec != null) {
            try {
                createTribbleIndex(ifile, outputFile, indexType, binSize, codec);
            } catch (TribbleException.MalformedFeatureFile e) {
View Full Code Here

    public static Genome loadGenome(String genomeFileOrID) throws IOException {

        String rootDir = FileUtils.getInstallDirectory();

        final GenomeManager genomeManager = GenomeManager.getInstance();
        Genome genome = genomeManager.getCurrentGenome();
        if (genome != null && genome.getId().equals(genomeFileOrID)) {
            return genome;
        }

        File genomeFile = new File(genomeFileOrID);
        if (!genomeFile.exists()) {
            genomeFile = new File(rootDir, "genomes" + File.separator + genomeFileOrID + ".genome");

        }
        if(!genomeFile.exists()) {
            genomeFile = new File(rootDir, "genomes" + File.separator + genomeFileOrID + ".chrom.sizes");
        }
        if (!genomeFile.exists()) {
            genomeFile = new File(rootDir, "genomes" + File.separator + genomeFileOrID);

        }
        if (!genomeFile.exists()) {
            throw new PreprocessingException("Genome definition file not found for: " + genomeFileOrID);
        }


        //TODO Prevents loading genome again if loading from path.
        //May or may not want this, for now we just use it for testing
        if (Globals.isTesting() && genomeFile.getAbsolutePath().endsWith(".genome")) {
            GenomeDescriptor genomeDescriptor = GenomeManager.parseGenomeArchiveFile(genomeFile);
            if (genome != null && genomeDescriptor.getId().equals(genome.getId())) {
                return genome;
            }
        }

        genome = genomeManager.loadGenome(genomeFile.getAbsolutePath(), null);
View Full Code Here

    public static JMenuItem getCopySequenceItem(final Feature f) {
        JMenuItem item = new JMenuItem("Copy Sequence");
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                Genome genome = GenomeManager.getInstance().getCurrentGenome();
                IGV.copySequenceToClipboard(genome, f.getChr(), f.getStart(), f.getEnd());
            }
        });
        return item;
    }
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.