use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class GenotypeMatrixTest method canHandleVCFWithNoSamples.
@Test
public void canHandleVCFWithNoSamples() throws Exception {
GenomicCoords gc = new GenomicCoords("1:1-10000000", 80, null, null);
TrackIntervalFeature vcf = new TrackIntervalFeature("test_data/CHD.exon.2010_03.sites.vcf.gz", gc);
List<IntervalFeature> linf = vcf.getIntervalFeatureList();
// Make sure we do have some features otherwise the test is meaningless.
assertTrue(linf.size() > 0);
GenotypeMatrix gm = new GenotypeMatrix();
String x = gm.printToScreen(true, linf, 80, null);
assertTrue(x.isEmpty());
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class GenotypeMatrixTest method canSelectSamplesByRegex.
@Test
public void canSelectSamplesByRegex() throws Exception {
GenomicCoords gc = new GenomicCoords("1:572807-755079", 80, null, null);
TrackIntervalFeature vcf = new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz", gc);
List<IntervalFeature> linf = vcf.getIntervalFeatureList();
GenotypeMatrix gm = new GenotypeMatrix();
gm.setSelectSampleRegex("96|99");
// gm.makeMatrix(linf, 80, null);
String x = gm.printToScreen(true, linf, 80, null);
String[] rows = x.split("\n");
assertEquals(2, rows.length);
// Exclude all samples
gm.setSelectSampleRegex("^$");
// gm.makeMatrix(linf, 80, null);
assertTrue(gm.printToScreen(true, linf, 80, null).isEmpty());
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class GenotypeMatrixTest method genotypeKetwordInJS.
@Test
public void genotypeKetwordInJS() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, IOException {
VCFFileReader reader = new VCFFileReader(new File("test_data/info_formats.vcf.gz"));
VCFHeader vcfHeader = reader.getFileHeader();
reader.close();
GenomicCoords gc = new GenomicCoords("1:17822074-17822184", 80, null, null);
TrackIntervalFeature vcf = new TrackIntervalFeature("test_data/info_formats.vcf.gz", gc);
List<IntervalFeature> linf = vcf.getIntervalFeatureList();
GenotypeMatrix gm = new GenotypeMatrix();
gm.setJsScriptFilter("{HOM}");
String x = gm.printToScreen(true, linf, 80, vcfHeader);
assertTrue(x.contains("sample2"));
assertTrue(!x.contains("sample1"));
gm.setJsScriptFilter("{NO_CALL}");
x = gm.printToScreen(true, linf, 80, vcfHeader);
assertTrue(x.contains("sample1"));
assertTrue(!x.contains("sample2"));
gm.setJsScriptFilter("{HET_NON_REF}");
x = gm.printToScreen(true, linf, 80, vcfHeader);
assertTrue(x.contains("sample2"));
assertTrue(!x.contains("sample1"));
gm.setJsScriptFilter("{CALLED} && {POS} == 17822094");
x = gm.printToScreen(true, linf, 80, vcfHeader);
assertTrue(x.contains("sample2"));
assertTrue(!x.contains("sample1"));
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class GenotypeMatrixTest method canInitMatrix.
@Test
public void canInitMatrix() throws IOException, InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException {
VCFFileReader reader = new VCFFileReader(new File("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz"));
VCFHeader vcfHeader = reader.getFileHeader();
reader.close();
GenomicCoords gc = new GenomicCoords("1:572807-755079", 80, null, null);
TrackIntervalFeature vcf = new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz", gc);
List<IntervalFeature> linf = vcf.getIntervalFeatureList();
GenotypeMatrix gm = new GenotypeMatrix();
// No feature at all
assertTrue(gm.printToScreen(true, new ArrayList<IntervalFeature>(), 80, vcfHeader).isEmpty());
String x = gm.printToScreen(true, linf, 80, vcfHeader);
// Check sample name
assertTrue(x.startsWith("HG00096"));
String[] rows = x.split("\n");
assertEquals(3, rows.length);
assertEquals(80, rows[0].length());
// Check genotype coding
// Missing genotype
assertTrue(rows[0].contains("?"));
// HOM ref
assertTrue(rows[0].contains("."));
// HET
assertTrue(rows[1].contains("E"));
// HOM alt
assertTrue(rows[2].contains("0"));
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackSetTest method canAddBookmarkTrack.
@Test
public void canAddBookmarkTrack() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException, InvalidCommandLineException, InvalidConfigException {
new Config(null);
List<String> cmdInput = new ArrayList<String>();
cmdInput.add("bookmark");
cmdInput.add("bookmark_1");
TrackSet ts = new TrackSet();
GenomicCoords gc = new GenomicCoords("chr1:1-100", 80, null, null);
ts.bookmark(gc, cmdInput);
assertTrue(ts.getTrackList().size() == 1);
ts.getTrackList().get(0).setNoFormat(true);
GenomicCoords gc2 = new GenomicCoords("chr1:1-1000", 80, null, null);
ts.bookmark(gc2, cmdInput);
TrackBookmark bm = (TrackBookmark) ts.getTrackList().get(0);
assertEquals(2, bm.getIntervalFeatureList().size());
bm.setPrintMode(PrintRawLine.CLIP);
// NB: it prints twice the same gc becouse the position is nt changed
System.out.println(bm.printLines());
}
Aggregations