Search in sources :

Example 46 with GenomicCoords

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());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 47 with GenomicCoords

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());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 48 with GenomicCoords

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"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) VCFFileReader(htsjdk.variant.vcf.VCFFileReader) VCFHeader(htsjdk.variant.vcf.VCFHeader) File(java.io.File) Test(org.junit.Test)

Example 49 with GenomicCoords

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"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) VCFFileReader(htsjdk.variant.vcf.VCFFileReader) VCFHeader(htsjdk.variant.vcf.VCFHeader) File(java.io.File) Test(org.junit.Test)

Example 50 with GenomicCoords

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());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Config(coloring.Config) ArrayList(java.util.ArrayList) 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