Search in sources :

Example 86 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canPrintGFFRegionWithAndWithoutTranscripts.

@Test
public void canPrintGFFRegionWithAndWithoutTranscripts() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
    String intervalFileName = "test_data/Homo_sapiens.GRCh38.86.chromosome.7.gff3.gz";
    GenomicCoords gc = new GenomicCoords("7:1-100000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setNoFormat(true);
    System.err.println(tif.printToScreen());
    assertTrue(tif.printToScreen().contains("||||||"));
    assertTrue(tif.printToScreen().contains("eee"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 87 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canStackFeatures.

@Test
public void canStackFeatures() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
    String intervalFileName = "test_data/overlapped.bed";
    GenomicCoords gc = new GenomicCoords("chr1:1-70", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setNoFormat(true);
    assertEquals(70 * 2 + 1, tif.printToScreen().length());
    String exp = "" + ">>>>>>>>>>     >>>>>>>>>>>>>>>          <<<<<<<<<<                    \n" + "     >>>>>>>>>>>>>>>                                                  ";
    assertEquals(exp, tif.printToScreen());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 88 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canGetCoordsOfNextFeature.

@Test
public void canGetCoordsOfNextFeature() throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException {
    GenomicCoords gc = new GenomicCoords("chr1:8000000-20000000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature("test_data/refSeq.hg19.short.sort-2.bed", gc);
    GenomicCoords newGc = tif.coordsOfNextFeature(gc, false);
    assertEquals(25167428 + 1, (int) newGc.getFrom());
    assertEquals(25167428 + gc.getGenomicWindowSize(), (int) newGc.getTo());
    // Next feature is on next chrom, current chrom not in file at all.
    gc = new GenomicCoords("foo:1-10000", 80, null, null);
    newGc = tif.coordsOfNextFeature(gc, false);
    assertEquals("chr1", newGc.getChrom());
    gc = new GenomicCoords("chr1:100000000-101000000", 80, null, null);
    newGc = tif.coordsOfNextFeature(gc, false);
    assertEquals("chr3", newGc.getChrom());
    gc = new GenomicCoords("chr1:10000000-10001000", 80, null, null);
    newGc = tif.coordsOfNextFeature(gc, true);
    assertEquals(8404074, (int) newGc.getFrom());
    newGc = tif.coordsOfNextFeature(newGc, true);
    assertEquals(67208779, (int) newGc.getFrom());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 89 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canReadTabix.

@Test
public void canReadTabix() throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException {
    // "test_data/refSeq.hg19.short.sort.bed.gz";
    String bgzFn = "test_data/refSeq.hg19.short.sort.bed.gz";
    GenomicCoords gc = new GenomicCoords("chr1:16000000-20000000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(bgzFn, gc);
    List<IntervalFeature> xset = tif.getFeaturesInInterval(gc.getChrom(), gc.getFrom(), gc.getTo());
    assertEquals(3, xset.size());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 90 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canPrintNormalizedVcfLines.

@Test
public void canPrintNormalizedVcfLines() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, InvalidConfigException, InvalidCommandLineException {
    GenomicCoords gc = new GenomicCoords("1:645709-645975", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz", gc);
    tif.setPrintMode(PrintRawLine.FULL);
    tif.setNoFormat(true);
    tif.setPrintNormalizedVcf(true);
    assertEquals(3, tif.printLines().split("\n").length);
    assertTrue(tif.printLines().contains(" HG00096 GT"));
    // VCF with without samples
    gc = new GenomicCoords("1:1105467-1105647", 80, null, null);
    tif = new TrackIntervalFeature("test_data/CHD.exon.2010_03.sites.vcf.gz", gc);
    tif.setPrintMode(PrintRawLine.FULL);
    tif.setNoFormat(true);
    tif.setPrintNormalizedVcf(true);
    assertEquals(1, tif.printLines().split("\n").length);
}
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