Search in sources :

Example 1 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TextReadTest method canPrintFormattedRead.

@Test
public void canPrintFormattedRead() throws InvalidGenomicCoordsException, IOException, InvalidColourException {
    GenomicCoords gc = new GenomicCoords("chr7:5566778-5566798", 80, null, null);
    SAMRecord rec = new SAMRecord(null);
    rec.setAlignmentStart(5566780);
    rec.setCigarString("24M");
    rec.setReadBases("AACCGGTTAACCGGTTAACCGGTT".getBytes());
    TextRead textRead = new TextRead(rec, gc, false);
    rec.setSecondOfPairFlag(false);
    // '4': Underline
    assertTrue(!textRead.getPrintableTextRead(true, false, false).contains("4;"));
    rec.setSecondOfPairFlag(true);
    // '4': Underline
    assertTrue(textRead.getPrintableTextRead(true, false, false).contains("4;"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) SAMRecord(htsjdk.samtools.SAMRecord) Test(org.junit.Test)

Example 2 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TextReadTest method canPrintReadWithSkippedBases.

@Test
public void canPrintReadWithSkippedBases() throws InvalidGenomicCoordsException, IOException, InvalidColourException {
    GenomicCoords gc = new GenomicCoords("chr7:1-800", 80, samSeqDict, fastaFile);
    SAMRecord rec = new SAMRecord(null);
    rec.setAlignmentStart(1);
    rec.setCigarString("70M200N50M200N10M");
    TextRead textRead = new TextRead(rec, gc, false);
    System.out.println(textRead.getPrintableTextRead(false, true, false));
    assertTrue(textRead.getPrintableTextRead(false, true, false).startsWith(">"));
    assertTrue(textRead.getPrintableTextRead(false, true, false).endsWith(">"));
    assertTrue(textRead.getPrintableTextRead(false, true, false).contains("_"));
    // Very large skipped region: Only show the skipped part.
    rec.setCigarString("1M5000N1M");
    textRead = new TextRead(rec, gc, false);
    System.out.println(textRead.getPrintableTextRead(false, true, false));
    assertTrue("_", textRead.getPrintableTextRead(false, true, false).startsWith("_"));
    assertTrue("_", textRead.getPrintableTextRead(false, true, false).endsWith("_"));
    assertEquals("", textRead.getPrintableTextRead(false, true, false).replaceAll("_", ""));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) SAMRecord(htsjdk.samtools.SAMRecord) Test(org.junit.Test)

Example 3 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackBookmarkTest method canColorByRegex.

@Test
public void canColorByRegex() throws Exception {
    GenomicCoords gc = new GenomicCoords("chr1:1-100", 80, null, null);
    TrackBookmark bm = new TrackBookmark(gc, "book1");
    // This is to populate the ideograms.
    bm.printToScreen();
    List<Argument> colorForRegex = new ArrayList<Argument>();
    colorForRegex.add(new Argument(".*", "216", false));
    bm.setColorForRegex(colorForRegex);
    assertTrue(bm.printToScreen().contains("216"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canConstructTrack.

@Test
public void canConstructTrack() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
    String intervalFileName = "test_data/refSeq.bed";
    // IntervalFeatureSet ifs= new IntervalFeatureSet(new File(intervalFileName));
    GenomicCoords gc = new GenomicCoords("chr1:1-70", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setNoFormat(true);
    String exp = "||||||||||          ||||||||||                                        ";
    assertEquals(exp, tif.printToScreen());
    gc = new GenomicCoords("chr1:1-70", 80, null, null);
    tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setNoFormat(true);
    assertTrue(tif.printToScreen().startsWith("||||"));
    assertTrue(tif.printToScreen().endsWith("    "));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 5 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canShowAndHide_getFeaturesInInterval.

@Test
public void canShowAndHide_getFeaturesInInterval() throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException {
    String intervalFileName = "test_data/hg19_genes_head.gtf.gz";
    GenomicCoords gc = new GenomicCoords("chr1:10000-100000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setShowHideRegex(Pattern.compile("start_codon"), Pattern.compile("OR4F"));
    List<IntervalFeature> subset = tif.getFeaturesInInterval("chr1", 1, 500000000);
    assertEquals(40, subset.size());
}
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