Search in sources :

Example 26 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canReadFeaturesOfLengthOne.

@Test
public void canReadFeaturesOfLengthOne() throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException {
    GenomicCoords gc = new GenomicCoords("chr18:1-10000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature("test_data/refSeqZero.bed", gc);
    List<IntervalFeature> xset = tif.getFeaturesInInterval("chr1", 1, 100);
    assertEquals(1, xset.size());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 27 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canReadVCFTabix.

@Test
public void canReadVCFTabix() throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException {
    GenomicCoords gc = new GenomicCoords("chr18:1-10000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature("test_data/CHD.exon.2010_03.sites.vcf.gz", gc);
    List<IntervalFeature> xset = tif.getFeaturesInInterval("1", 1, 10000000);
    assertEquals(9, xset.size());
    IntervalFeature x = xset.get(1);
    assertEquals("1", x.getChrom());
    assertEquals(1108138, x.getFrom());
    System.err.println(tif.printToScreen());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 28 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canReadTabixVCFFromLocal.

@Test
public void canReadTabixVCFFromLocal() throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException {
    String bgzFn = "test_data/CHD.exon.2010_03.sites.vcf.gz";
    GenomicCoords gc = new GenomicCoords("1:1-2000000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(bgzFn, gc);
    assertEquals(3, tif.getIntervalFeatureList().size());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 29 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackPileupTest method sameAsMpileup.

@Test
public void sameAsMpileup() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException {
    GenomicCoords gc = new GenomicCoords("chr7:5522059-5612125", 80, null, null);
    TrackPileup tr = new TrackPileup("test_data/ear045.oxBS.actb.bam", gc);
    // Pileup file created with:
    // samtools mpileup -A -q 0 -Q 0 -x --ff 0 test_data/ear045.oxBS.actb.bam | cut -f 1-4 | gzip > test_data/ear045.oxBS.actb.pileup.gz
    List<String> expList = this.gzipFileToList("test_data/ear045.oxBS.actb.pileup.gz");
    // Positions are returned unsorted! We need to sort them first.
    Map<Integer, Integer> depth = tr.getDepth(gc.getChrom(), gc.getFrom(), gc.getTo());
    List<Integer> positions = new ArrayList<Integer>();
    positions.addAll(depth.keySet());
    Collections.sort(positions);
    // mpileup and TrackPileup hit the same positions
    assertEquals(expList.size(), depth.size());
    // Same depth at same positions
    int i = 0;
    for (int obsPos : positions) {
        int obsDepth = depth.get(obsPos);
        int expPos = Integer.parseInt(Splitter.on("\t").splitToList(expList.get(i)).get(1));
        int expDepth = Integer.parseInt(Splitter.on("\t").splitToList(expList.get(i)).get(3));
        try {
            assertEquals(expPos, obsPos);
            assertEquals(expDepth, obsDepth);
        } catch (AssertionError e) {
            System.err.println("At iteration: " + i);
            System.err.println(expList.get(i));
            System.err.println("Observed depth: " + obsDepth);
            throw e;
        }
        i++;
    }
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 30 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackPileupTest method canReloadTrack.

@Test
public void canReloadTrack() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException {
    GenomicCoords gc = new GenomicCoords("chr7:1-200", 80, null, null);
    TrackPileup tr = new TrackPileup("test_data/pairs.sam", gc);
    tr.reload();
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Aggregations

GenomicCoords (samTextViewer.GenomicCoords)156 Test (org.junit.Test)147 File (java.io.File)10 ArrayList (java.util.ArrayList)9 Config (coloring.Config)8 VCFFileReader (htsjdk.variant.vcf.VCFFileReader)8 VCFHeader (htsjdk.variant.vcf.VCFHeader)8 SAMRecord (htsjdk.samtools.SAMRecord)6 InvalidCommandLineException (exceptions.InvalidCommandLineException)3 InvalidGenomicCoordsException (exceptions.InvalidGenomicCoordsException)1 MappingQualityFilter (htsjdk.samtools.filter.MappingQualityFilter)1 SamRecordFilter (htsjdk.samtools.filter.SamRecordFilter)1 IOException (java.io.IOException)1 TrackReads (tracks.TrackReads)1