use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackSetTest method canConstructTrackSetFromURL.
@Test
public void canConstructTrackSetFromURL() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, BamIndexNotFoundException, InvalidRecordException, SQLException {
GenomicCoords gc = new GenomicCoords("chr7:5565052-5571960", 80, null, null);
TrackSet trackSet = new TrackSet();
trackSet.addTrackFromSource("http://hgdownload.cse.ucsc.edu/goldenpath/hg19/encodeDCC/wgEncodeCaltechRnaSeq/wgEncodeCaltechRnaSeqGm12878R2x75Il400SigRep2V2.bigWig", gc, null);
trackSet.addTrackFromSource("http://hgdownload.cse.ucsc.edu/goldenpath/hg19/encodeDCC/wgEncodeCaltechRnaSeq/wgEncodeCaltechRnaSeqGm12878R2x75Il400JunctionsRep2V3.bigBed", gc, null);
trackSet.addTrackFromSource("http://hgdownload.cse.ucsc.edu/goldenpath/hg19/encodeDCC/wgEncodeCaltechRnaSeq/wgEncodeCaltechRnaSeqGm12878R2x75Il400GeneGencV3cRep2V3.gtf.gz", gc, null);
trackSet.addTrackFromSource("http://hgdownload.cse.ucsc.edu/goldenpath/hg19/encodeDCC/wgEncodeCaltechRnaSeq/wgEncodeCaltechRnaSeqGm12878R2x75Il400SigRep2V2.bigWig", gc, null);
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackSetTest method canSetVariantReadsFilter.
@Test
public void canSetVariantReadsFilter() throws InvalidCommandLineException, InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
GenomicCoords gc = new GenomicCoords("chr7:1-1000", 80, null, "test_data/chr7.fa");
TrackSet ts = new TrackSet();
Track t1 = new TrackReads("test_data/ds051.actb.bam", gc);
ts.addTrack(t1, "x");
Track t2 = new TrackReads("test_data/ds051.actb.bam", gc);
ts.addTrack(t2, "x");
Track t3 = new TrackReads("test_data/ds051.actb.bam", gc);
ts.addTrack(t3, "x");
ts.setFilterVariantReads(Utils.tokenize("filterVariantReads -r 1:10", " "));
assertEquals(1, t1.getFeatureFilter().getVariantFrom());
assertEquals(10, t1.getFeatureFilter().getVariantTo());
assertEquals(1, t2.getFeatureFilter().getVariantFrom());
assertEquals(10, t2.getFeatureFilter().getVariantTo());
ts.setFilterVariantReads(Utils.tokenize("filterVariantReads -r 1", " "));
assertEquals(1, t1.getFeatureFilter().getVariantFrom());
assertEquals(1, t1.getFeatureFilter().getVariantTo());
// With spaces use single quotes
ts.setFilterVariantReads(Utils.tokenize("filterVariantReads -r '100 +/- 5'", " "));
assertEquals(95, t1.getFeatureFilter().getVariantFrom());
assertEquals(105, t1.getFeatureFilter().getVariantTo());
ts.setFilterVariantReads(Utils.tokenize("filterVariantReads -r 100+-5", " "));
assertEquals(95, t1.getFeatureFilter().getVariantFrom());
assertEquals(105, t1.getFeatureFilter().getVariantTo());
ts.setFilterVariantReads(Utils.tokenize("filterVariantReads -r 100+5", " "));
assertEquals(100, t1.getFeatureFilter().getVariantFrom());
assertEquals(105, t1.getFeatureFilter().getVariantTo());
ts.setFilterVariantReads(Utils.tokenize("filterVariantReads -r 100-5", " "));
assertEquals(95, t1.getFeatureFilter().getVariantFrom());
assertEquals(100, t1.getFeatureFilter().getVariantTo());
ts.setFilterVariantReads(Utils.tokenize("filterVariantReads -r 100-200", " "));
assertEquals(1, t1.getFeatureFilter().getVariantFrom());
assertEquals(100, t1.getFeatureFilter().getVariantTo());
// Remove filter for this regex track
ts.setFilterVariantReads(Utils.tokenize("filterVariantReads #1", " "));
assertEquals(Filter.DEFAULT_VARIANT_CHROM.getValue(), t1.getFeatureFilter().getVariantChrom());
assertEquals("chr7", t2.getFeatureFilter().getVariantChrom());
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackSetTest method canSetTrackHeight.
@Test
public void canSetTrackHeight() throws InvalidCommandLineException, IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException {
String intervalFileName = "test_data/bgz_noindex.vcf.bgz";
GenomicCoords gc = new GenomicCoords("1:1-200000000", 80, null, null);
TrackSet ts = new TrackSet();
Track t1 = new TrackIntervalFeature(intervalFileName, gc);
ts.addTrack(t1, "x");
Track t2 = new TrackIntervalFeature(intervalFileName, gc);
ts.addTrack(t2, "x");
Track t3 = new TrackIntervalFeature(intervalFileName, gc);
ts.addTrack(t3, "x");
String cmdInput = "trackHeight 2 #1 #3";
ts.setTrackHeightForRegex(Utils.tokenize(cmdInput, " "));
assertEquals(2, ts.getTrack(t1).getyMaxLines());
assertEquals(10, ts.getTrack(t2).getyMaxLines());
assertEquals(2, ts.getTrack(t3).getyMaxLines());
// Defsult regex: All tracks captured
cmdInput = "trackHeight 99";
ts.setTrackHeightForRegex(Utils.tokenize(cmdInput, " "));
assertEquals(99, ts.getTrack(t1).getyMaxLines());
assertEquals(99, ts.getTrack(t2).getyMaxLines());
assertEquals(99, ts.getTrack(t3).getyMaxLines());
// Invert selection
cmdInput = "trackHeight -v 10 #1";
ts.setTrackHeightForRegex(Utils.tokenize(cmdInput, " "));
assertEquals(99, ts.getTrack(t1).getyMaxLines());
assertEquals(10, ts.getTrack(t2).getyMaxLines());
assertEquals(10, ts.getTrack(t3).getyMaxLines());
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackSetTest method canPrintFeaturesToFile.
@Test
public void canPrintFeaturesToFile() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, BamIndexNotFoundException, InvalidRecordException, SQLException, InvalidCommandLineException, InvalidColourException, ArgumentParserException {
// --------------------------------------------------------------------
// Prepare coords and trackSet
GenomicCoords gc = new GenomicCoords("chr7:5565052-5571960", 80, null, null);
TrackSet trackSet = new TrackSet();
trackSet.addTrackFromSource("test_data/hg19_genes.gtf.gz", gc, null);
trackSet.addTrackFromSource("test_data/hg19_genes.gtf.gz", gc, null);
// --------------------------------------------------------------------
// No redirection file: Nothing done
List<String> cmdInput = Utils.tokenize("print #1 >", " ");
boolean failed = false;
try {
trackSet.setPrintModeAndPrintFeaturesForRegex(cmdInput);
} catch (InvalidCommandLineException e) {
failed = true;
}
assertTrue(failed);
// Invalid output: Non existent dir:
cmdInput = Utils.tokenize("print #1 > test_data/foobar/delete.me", " ");
failed = false;
try {
trackSet.setPrintModeAndPrintFeaturesForRegex(cmdInput);
} catch (IOException e) {
failed = true;
}
assertTrue(failed);
// Now give an output file.
File ff = new File("deleteme.gtf");
ff.deleteOnExit();
cmdInput = Utils.tokenize("print #1 > deleteme.gtf", " ");
trackSet.setPrintModeAndPrintFeaturesForRegex(cmdInput);
assertTrue(ff.exists());
assertTrue(ff.length() > 200);
assertEquals(13, FileUtils.readLines(ff).size());
// Append to file
cmdInput = Utils.tokenize("print #1 >> deleteme.gtf", " ");
trackSet.setPrintModeAndPrintFeaturesForRegex(cmdInput);
assertEquals(26, FileUtils.readLines(ff).size());
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackSetTest method canReplaceOverloadedFunctionInAwk.
@Test
public void canReplaceOverloadedFunctionInAwk() throws Exception {
TrackSet ts = new TrackSet();
GenomicCoords gc = new GenomicCoords("chr1:1-100", 80, null, null);
Track t1 = new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf", gc);
ts.addTrack(t1, "vcf");
Track t2 = new TrackPileup("test_data/ds051.actb.bam", gc);
ts.addTrack(t2, "bam");
Track t3 = new TrackIntervalFeature("test_data/refSeq.bed", gc);
ts.addTrack(t3, "bed");
ts.setAwkForTrack(Utils.tokenize("awk 'get(AC) > 2 ||get(GT, 2, 1) && get(INFO/FOO) && get(FMT/BAR)' vcf", " "));
assertTrue(ts.getTrack(t1).getAwk().endsWith("'"));
assertTrue(ts.getTrack(t1).getAwk().contains("getInfoTag(\"AC\")"));
assertTrue(ts.getTrack(t1).getAwk().contains("getFmtTag(\"GT\", 2, 1)"));
assertTrue(ts.getTrack(t1).getAwk().contains("getInfoTag(\"INFO/FOO\")"));
assertTrue(ts.getTrack(t1).getAwk().contains("getFmtTag(\"FMT/BAR\")"));
boolean pass = false;
try {
// BAR not qualified by INFO/ or FMT/
ts.setAwkForTrack(Utils.tokenize("awk 'get(BAR)' vcf", " "));
} catch (InvalidCommandLineException e) {
pass = true;
}
assertTrue(pass);
ts.setAwkForTrack(Utils.tokenize("awk 'get( NM ) > 2' bam", " "));
assertTrue(ts.getTrack(t2).getAwk().contains("getSamTag(\"NM\")"));
pass = false;
try {
// Can't use get() on BED
ts.setAwkForTrack(Utils.tokenize("awk 'get(NM)' bed", " "));
} catch (InvalidCommandLineException e) {
pass = true;
}
assertTrue(pass);
// Nothing to replace
String awk = "awk 'foo_get() get (bar)' vcf";
ts.setAwkForTrack(Utils.tokenize(awk, " "));
assertTrue(ts.getTrack(t1).getAwk().contains("foo_get() get (bar)"));
}
Aggregations