Search in sources :

Example 91 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canStackFeaturesInBlocksToOneLine.

@Test
public void canStackFeaturesInBlocksToOneLine() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
    // Test to reproduce issue#80
    String intervalFileName = "test_data/ovl.gff";
    GenomicCoords gc = new GenomicCoords("1:1-200", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setNoFormat(true);
    tif.setFeatureDisplayMode(FeatureDisplayMode.ONELINE);
    assertTrue(tif.printToScreen().trim().contains("|||   |||"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 92 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canChangeFeatureName.

@Test
public void canChangeFeatureName() throws Exception {
    // Complete GFF transscript
    String intervalFileName = "test_data/Homo_sapiens.GRCh38.86.ENST00000331789.gff3";
    GenomicCoords gc = new GenomicCoords("7:5527151-5530709", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setNoFormat(true);
    tif.setGtfAttributeForName("ID");
    assertTrue(tif.printToScreen().contains("transcript:ENS"));
    tif.setGtfAttributeForName("Name");
    assertTrue(tif.printToScreen().contains("ACTB-001"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 93 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canApplyAwkAndGrep_getFeaturesInInterval.

@Test
public void canApplyAwkAndGrep_getFeaturesInInterval() throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException {
    String intervalFileName = "test_data/hg19_genes_head.gtf.gz";
    GenomicCoords gc = new GenomicCoords("chr1:10000-100000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setAwk("'$3 == \"start_codon\"");
    tif.setShowHideRegex(Pattern.compile(Filter.DEFAULT_SHOW_REGEX.getValue()), Pattern.compile("OR4F"));
    List<IntervalFeature> subset = tif.getFeaturesInInterval("chr1", 1, 500000000);
    assertEquals(40, subset.size());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 94 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canGetCoordsOfPreviousFeature.

@Test
public void canGetCoordsOfPreviousFeature() 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);
    gc = new GenomicCoords("chr1:10000000-10001000", 80, null, null);
    GenomicCoords newGc = tif.coordsOfNextFeature(gc, true);
    assertEquals(8404074, (int) newGc.getFrom());
    newGc = tif.coordsOfNextFeature(newGc, true);
    assertEquals(67208779, (int) newGc.getFrom());
    // Exactly at the start of a feature and move to previous one. This is the feature:
    // chrM hg19_wgEncodeGencodeBasicV19 exon 15957 16024 ...
    gc = new GenomicCoords("chrM:15957-17259", 80, null, null);
    tif = new TrackIntervalFeature("test_data/hg19.gencode_genes_v19.gtf.gz", gc);
    newGc = tif.coordsOfNextFeature(gc, true);
    // chrM hg19_wgEncodeGencodeBasicV19 exon 15889 15954
    assertEquals(15889, (int) newGc.getFrom());
    gc = new GenomicCoords("chrM:14672-14898", 80, null, null);
    tif = new TrackIntervalFeature("test_data/hg19.gencode_genes_v19.gtf.gz", gc);
    newGc = tif.coordsOfNextFeature(gc, true);
    assertEquals(14150, (int) newGc.getFrom());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 95 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackIntervalFeatureTest method canAssignFeatureText.

@Test
public void canAssignFeatureText() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException {
    String intervalFileName = "test_data/hg19_genes_head.gtf";
    GenomicCoords gc = new GenomicCoords("chr1:11874-12227", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature(intervalFileName, gc);
    tif.setNoFormat(true);
    tif.setGtfAttributeForName("-na");
    assertTrue(tif.printToScreen().startsWith("EEEEE"));
}
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