Search in sources :

Example 76 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TextReadTest method canShadeBaseQuality.

@Test
public void canShadeBaseQuality() throws InvalidGenomicCoordsException, IOException, InvalidColourException {
    GenomicCoords gc = new GenomicCoords("chr7:1-80", 80, null, null);
    SAMRecord rec = new SAMRecord(null);
    rec.setAlignmentStart(1);
    rec.setCigarString("2M3D8M");
    rec.setMappingQuality(30);
    rec.setReadBases("AAAAATTTTT".getBytes());
    rec.setBaseQualities("!!!!!IIIII".getBytes());
    System.err.println(rec.getSAMString());
    TextRead tr = new TextRead(rec, gc, false);
    System.err.println(Splitter.on("m").omitEmptyStrings().splitToList(tr.getPrintableTextRead(false, false, false)));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) SAMRecord(htsjdk.samtools.SAMRecord) Test(org.junit.Test)

Example 77 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackBookmarkTest method canPrintBookmarksAsList.

@Test
public void canPrintBookmarksAsList() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
    GenomicCoords gc = new GenomicCoords("chr1:1-100", 80, null, null);
    TrackBookmark bm = new TrackBookmark(gc, "book1");
    bm.setNoFormat(true);
    gc = new GenomicCoords("chr1:200-300", 80, null, null);
    bm.setGc(gc);
    bm.addBookmark(gc, "book2");
    gc = new GenomicCoords("chr2:2000-3000", 80, null, null);
    bm.setGc(gc);
    bm.addBookmark(gc, "foo bar");
    assertEquals(3, bm.asList().size());
    assertTrue(bm.asList().get(1).contains("chr1:200-300"));
    assertTrue(bm.asList().get(2).contains("foo bar"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 78 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackBookmarkTest method canAddIntervalsToTrackBookmark.

@Test
public void canAddIntervalsToTrackBookmark() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
    GenomicCoords gc = new GenomicCoords("chr1:1-100", 80, null, null);
    TrackBookmark bm = new TrackBookmark(gc, "book1");
    bm.setNoFormat(true);
    gc = new GenomicCoords("chr1:400-500", 80, null, null);
    // Move track to this position w/o adding this pos to bookmarks.
    bm.setGc(gc);
    gc = new GenomicCoords("chr1:200-300", 80, null, null);
    bm.setGc(gc);
    bm.addBookmark(gc, "book2");
    gc = new GenomicCoords("chr1:1-1000", 80, null, null);
    bm.setGc(gc);
    assertTrue(bm.getIntervalFeatureList().size() == 2);
    // Can set name
    assertEquals("book2", bm.getIntervalFeatureList().get(1).getName());
    System.out.println(bm.printToScreen());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 79 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackBookmarkTest method canRemoveBookmark.

@Test
public void canRemoveBookmark() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
    GenomicCoords gc = new GenomicCoords("chr1:1-100", 80, null, null);
    TrackBookmark bm = new TrackBookmark(gc, "book1");
    bm.setNoFormat(true);
    gc = new GenomicCoords("chr1:200-300", 80, null, null);
    bm.setGc(gc);
    bm.addBookmark(gc, "book2");
    // Zoom out to span both bookmarks.
    gc = new GenomicCoords("chr1:1-1000", 80, null, null);
    bm.setGc(gc);
    // Just check we created a correct test object with two intervals
    assertEquals(2, bm.getIntervalFeatureList().size());
    // Partial overlap not touched
    gc = new GenomicCoords("chr1:1-1000", 80, null, null);
    bm.setGc(gc);
    bm.removeBookmark(gc);
    assertEquals(2, bm.getIntervalFeatureList().size());
    // Go to first bookmark and remove it:
    gc = new GenomicCoords("chr1:1-100", 80, null, null);
    bm.setGc(gc);
    bm.removeBookmark(gc);
    bm.setGc(new GenomicCoords("chr1:1-1000", 80, null, null));
    assertEquals(1, bm.getIntervalFeatureList().size());
    // Go to second bookmark and remove it. No bookmarks left:
    gc = new GenomicCoords("chr1:200-300", 80, null, null);
    bm.setGc(gc);
    bm.removeBookmark(gc);
    assertTrue(bm.getIntervalFeatureList().size() == 0);
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 80 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canReadUnsortedVCF.

@Test
public void canReadUnsortedVCF() 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.unsorted.vcf", 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());
}
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