Examples of IGVBEDCodec


Examples of org.broad.igv.feature.tribble.IGVBEDCodec

    private int writeFeaturesToStream(Iterator<Feature> features, OutputStream outputStream) {
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream));

        int allNumCols = -1;
        if (features != null) {
            IGVBEDCodec codec = new IGVBEDCodec();
            while (features.hasNext()) {
                String data = codec.encode(features.next());

                writer.println(data);

                //We require consistency of output
                int tmpNumCols = data.split("\t").length;
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

        //Read back in the data which bedtools output
        BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));

        List<Feature> featuresList = new ArrayList<Feature>();
        //TODO This cast is here as a reminder that we want to use AsciiFeatureCodec
        IGVBEDCodec codec = (IGVBEDCodec) CodecFactory.getCodec(".bed", null);

        String line;
        Feature feat;
        int numCols0 = tempFiles.get(fiNames[0]);
        int numCols1 = tempFiles.get(fiNames[1]);
        while ((line = in.readLine()) != null) {
            //System.out.println(line);
            String[] tokens = line.split("\t");
            if (operation.getCmd().contains("-split")) {
                //When we split, the returned feature still has the exons
                //We don't want to plot them all a zillion times
                tokens = Arrays.copyOfRange(tokens, 0, Math.min(6, tokens.length));
            }

            if (operation == Operation.WINDOW || operation == Operation.CLOSEST) {

                String[] closest = Arrays.copyOfRange(tokens, numCols0, numCols0 + numCols1);
                //If not found, bedtools returns -1 for positions
                if (closest[1].trim().equalsIgnoreCase("-1")) {
                    continue;
                }
                feat = codec.decode(closest);
            } else if (operation == Operation.MULTIINTER) {
                //We only look at regions common to ALL inputs
                //Columns: chr \t start \t \end \t # of files which contained this feature \t comma-separated list files +many more
                int numRegions = Integer.parseInt(tokens[3]);
                if (numRegions < sources.length) {
                    continue;
                }
                String[] intersection = Arrays.copyOf(tokens, 3);
                feat = codec.decode(intersection);
            } else {
                feat = codec.decode(tokens);
            }
            featuresList.add(feat);
        }

        in.close();
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

    }

    @Test
    public void testIntervalTest() throws Exception {
        intervalTestFile(new BEDCodec());
        intervalTestFile(new IGVBEDCodec());
    }
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

    @Test
    public void testLargeBedNoHeader() throws Exception {
        String bedFile = TestUtils.DATA_DIR + "bed/Unigene.noheader.sorted.bed";
        tstUnigeneBed(bedFile, new BEDCodec());

        tstUnigeneBed(bedFile, new IGVBEDCodec());
    }
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

    @Test
    public void testLargeBedWithHeader() throws Exception {
        String bedFile = TestUtils.DATA_DIR + "bed/Unigene.withheader.sorted.bed";
        tstUnigeneBed(bedFile, new BEDCodec());

        tstUnigeneBed(bedFile, new IGVBEDCodec());
    }
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

    @Test
    public void testLargeBedWeirdHeader() throws Exception {
        String bedFile = TestUtils.DATA_DIR + "bed/Unigene.weirdheader.sorted.bed";
        tstUnigeneBed(bedFile, new BEDCodec());

        tstUnigeneBed(bedFile, new IGVBEDCodec());
    }
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

    @Test
    public void testLargeBedNoTrack() throws Exception {
        String bedFile = TestUtils.DATA_DIR + "bed/Unigene.notrack.sorted.bed";
        tstUnigeneBed(bedFile, new BEDCodec());

        tstUnigeneBed(bedFile, new IGVBEDCodec());
    }
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

        String bedFile = TestUtils.DATA_DIR + "bed/gene.bed";
        Genome genome = TestUtils.loadGenome();

        FeatureCodec codec1 = CodecFactory.getCodec(bedFile, genome);
        assertTrue(codec1 instanceof IGVBEDCodec);
        IGVBEDCodec codec = (IGVBEDCodec) codec1;

        AbstractFeatureReader bfr = AbstractFeatureReader.getFeatureReader(bedFile, codec, false);
        FeatureFileHeader header = (FeatureFileHeader) bfr.getHeader();
        Assert.assertNotNull(header);
        assertTrue(codec.isGffTags());

        Iterator<BasicFeature> iter = bfr.iterator();
        while (iter.hasNext()) {
            BasicFeature feat = iter.next();
            //Note: These are not in general equal, but they are for this data file
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

     * @throws Exception
     */
    @Test
    public void testJunctionFile() throws Exception {
        String bedFile = TestUtils.DATA_DIR + "bed/mini.junctions.bed";
        AbstractFeatureReader bfr = AbstractFeatureReader.getFeatureReader(bedFile, new IGVBEDCodec(), false);
        Iterator<BasicFeature> iter = bfr.iterator();
        while (iter.hasNext()) {
            BasicFeature feature = iter.next();
            assertTrue( feature instanceof SpliceJunctionFeature);
            SpliceJunctionFeature sjf = (SpliceJunctionFeature) feature;
View Full Code Here

Examples of org.broad.igv.feature.tribble.IGVBEDCodec

        ResultSet rs = DBManagerTest.getAllFromSQLTable("sql/unigene.db", "unigene");
        InputStream is = new SQLInputStream(rs, true);
        BufferedReader in = new BufferedReader(new InputStreamReader(is));
        int totalLines = 0;
        String val = "";
        AsciiFeatureCodec featureCodec = new IGVBEDCodec(genome);
        while ((val = in.readLine()) != null) {
            Feature feat = featureCodec.decode(val);
            checkFeatureIntegrity(feat, "chr2");
            totalLines += 1;
        }
        assertEquals(72, totalLines);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.