use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackTest method canHighlightFormatInVcfLines.
@Test
public void canHighlightFormatInVcfLines() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, InvalidCommandLineException {
GenomicCoords gc = new GenomicCoords("1:1-20000000", 80, null, null);
TrackIntervalFeature tif = new TrackIntervalFeature("test_data/info_formats.vcf.gz", gc);
tif.setPrintMode(PrintRawLine.FULL);
// Highlight FORMAT tag and associated values
tif.setHighlightPattern(Pattern.compile("GT"));
String out = tif.printLines();
assertTrue(out.contains("\033[7mGT\033[27m"));
assertTrue(out.contains("\033[7m1/0\033[27m"));
assertTrue(out.contains("\033[7m1|2\033[27m"));
// // Tag GTFF is not highlighted because the match is partial
// assertTrue(out.contains("\033[7m1|2\033[27m:100:0,0"));
//
// // This should match both:
// tif.setHighlightPattern(Pattern.compile("GT|GTFF"));
// // TODO: assertTrue(out.contains("\033[7m1|2\033[27m:100:0,0"));
// Turn the string-table to back to a list and ensure that all fields are there
List<String> xlist = Splitter.on("\t").omitEmptyStrings().splitToList(out.replaceAll(" +|\n", "\t"));
assertEquals(33, xlist.size());
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackTest method canPrintVcfWithClippedSeq.
@Test
public void canPrintVcfWithClippedSeq() throws InvalidGenomicCoordsException, IOException, InvalidColourException, InvalidCommandLineException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidConfigException {
new Config(null);
GenomicCoords gc = new GenomicCoords("1:1019492-1019672", 160, null, null);
TrackIntervalFeature tif = new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf", gc);
tif.setNoFormat(true);
tif.setPrintMode(PrintRawLine.CLIP);
assertTrue(tif.printLines().contains(" GTCAC["));
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackTest method canHighlightPrintableLines.
@Test
public void canHighlightPrintableLines() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, InvalidCommandLineException {
GenomicCoords gc = new GenomicCoords("1:1-400000", 80, null, null);
TrackIntervalFeature tif = new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf", gc);
tif.setPrintMode(PrintRawLine.FULL);
tif.setHighlightPattern(Pattern.compile("200000"));
String out = tif.printLines();
assertTrue(out.contains("\033[7m200000\033[27m"));
// Multiple patterns
tif.setHighlightPattern(Pattern.compile("ALU"));
out = tif.printLines();
assertTrue(out.contains("\033[7mALU\033[27m"));
// Pattern start of line
tif.setHighlightPattern(Pattern.compile("1"));
tif.setPrintMode(PrintRawLine.FULL);
out = tif.printLines();
assertTrue(out.startsWith("\033[38;5;0;48;5;231m\033[7m1[27m"));
// Pattern EOL
tif.setHighlightPattern(Pattern.compile("1\\|1"));
out = tif.printLines();
assertTrue(out.trim().endsWith("1|1\033[27m"));
// No pattern
tif.setHighlightPattern(Pattern.compile("FOOBAR"));
out = tif.printLines();
assertTrue(!out.contains("\033[7m"));
// Reset
tif.setHighlightPattern(Pattern.compile(""));
out = tif.printLines();
assertTrue(!out.contains("\033[7m"));
// Highlight FORMAT tag and associated values
tif.setHighlightPattern(Pattern.compile("GT"));
out = tif.printLines();
assertTrue(out.contains("\033[7mGT\033[27m"));
assertTrue(out.contains("\033[7m.|.\033[27m"));
assertTrue(out.contains("\033[7m0|0\033[27m"));
// Turn the string-table to back to a list and ensure that all fields are there
List<String> xlist = Splitter.on("\t").omitEmptyStrings().splitToList(out.replaceAll(" +|\n", "\t"));
assertEquals(24, xlist.size());
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackTest method canParsePrintableLinesWithInvalidCommand.
@Test
public void canParsePrintableLinesWithInvalidCommand() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, InvalidCommandLineException {
// Invalid command: Empty output. But note that no exception is thrown!
GenomicCoords gc = new GenomicCoords("chr1:1-100000", 80, null, null);
TrackIntervalFeature tif = new TrackIntervalFeature("test_data/hg19_genes_head.gtf", gc);
tif.setSystemCommandForPrint("foo");
assertEquals("", tif.printLines());
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackWigglesTest method invalidBedgraphRecordAsNaN.
@Test
public void invalidBedgraphRecordAsNaN() throws IOException, NoSuchAlgorithmException, InvalidGenomicCoordsException, InvalidRecordException, ClassNotFoundException, SQLException {
GenomicCoords gc = new GenomicCoords("chr1:1-10", 10, null, null);
TrackWiggles tw = new TrackWiggles("test_data/invalid-1.bedgraph", gc, 4);
assertEquals(tw.getScreenScores().get(0), Float.NaN, 0.0001);
assertEquals(tw.getScreenScores().get(1), 10, 0.0001);
}
Aggregations