Search in sources :

Example 36 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackReadsTest method canPrintReads.

@Test
public void canPrintReads() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException, InvalidConfigException, InvalidCommandLineException {
    GenomicCoords gc = new GenomicCoords("chr7:5566000-5567000", 80, null, null);
    TrackReads tr = new TrackReads("test_data/ds051.short.bam", gc);
    tr.setNoFormat(true);
    tr.setPrintMode(PrintRawLine.OFF);
    String printable = tr.printLines();
    // Empty string if printing is off.
    assertEquals("", printable);
    tr.setPrintMode(PrintRawLine.CLIP);
    tr.setPrintRawLineCount(5);
    printable = tr.printLines();
    assertTrue(printable.length() > 100);
    // Expect 6 lines: 5 for reads and 1 for info header.
    assertEquals(5 + 1, printable.split("\n").length);
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 37 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackReadsTest method canShowActiveFiltersInTitle.

@Test
public void canShowActiveFiltersInTitle() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException {
    String bam = "test_data/adjacent.bam";
    GenomicCoords gc = new GenomicCoords("chr7:1-100", 80, null, fastaFile);
    TrackReads tr = new TrackReads(bam, gc);
    tr.setNoFormat(true);
    assertTrue(!tr.getTitle().contains("filters"));
    tr.setMapq(Integer.valueOf(Filter.DEFAULT_MAPQ.getValue()));
    assertTrue(!tr.getTitle().contains("filters"));
    tr.setMapq(10);
    assertTrue(tr.getTitle().contains("mapq"));
    tr.set_F_flag(1024);
    assertTrue(tr.getTitle().contains("flag"));
    tr.setShowHideRegex(Pattern.compile(".*"), Pattern.compile("foo"));
    assertTrue(tr.getTitle().contains("grep"));
    tr.setVariantReadInInterval("chr7", 10, 100, true);
    assertTrue(tr.getTitle().contains("var-read"));
    tr.setAwk("'2 > 1'");
    assertTrue(tr.getTitle().contains("awk"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 38 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackReadsTest method canFilterReadsWithGrepAndAwk.

@Test
public void canFilterReadsWithGrepAndAwk() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException {
    GenomicCoords gc = new GenomicCoords("chr7:5566000-5567000", 80, samSeqDict, null);
    TrackReads tr = new TrackReads("test_data/ds051.short.bam", gc);
    tr.setNoFormat(true);
    tr.setyMaxLines(1000);
    // N. reads stacked in this interval before filtering
    assertEquals(22, tr.printToScreen().split("\n").length);
    tr.setShowHideRegex(Pattern.compile("NCNNNCCC"), Pattern.compile(Filter.DEFAULT_HIDE_REGEX.getValue()));
    tr.setAwk("'$4 != 5566779'");
    assertEquals(4, tr.printToScreen().split("\n").length);
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 39 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackReadsTest method canChangeReadColourOnRegex.

// @Test // STUB
public void canChangeReadColourOnRegex() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException {
    GenomicCoords gc = new GenomicCoords("chr7:5566778-5566943", 80, null, null);
    TrackReads tr = new TrackReads("test_data/ds051.short.bam", gc);
    List<Argument> list = new ArrayList<Argument>();
    Argument re = new Argument("NCNNNCCC", "red1", false);
    list.add(re);
    tr.changeFeatureColor(list);
    assertTrue(tr.printToScreen().contains("196;"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) ArrayList(java.util.ArrayList)

Example 40 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackReadsTest method canResetToZeroLargeWindow.

@Test
public void canResetToZeroLargeWindow() throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException {
    // If the genomic window is too large do not process the bam file and return zero height track.
    GenomicCoords gc = new GenomicCoords("chr7:1-100000000", 80, samSeqDict, fastaFile);
    TrackReads tr = new TrackReads("test_data/ds051.actb.bam", gc);
    assertEquals("", tr.printToScreen());
}
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