Search in sources :

Example 56 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackSetTest method canFilterGenotypeMatrix.

@Test
public void canFilterGenotypeMatrix() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException, InvalidCommandLineException {
    TrackSet ts = new TrackSet();
    GenomicCoords gc = new GenomicCoords("1:113054356-113054534", 80, null, null);
    String vcf = "test_data/CEU.exon.2010_06.genotypes.vcf";
    Track t1 = new TrackIntervalFeature(vcf, gc);
    ts.addTrack(t1, "x");
    t1.setNoFormat(true);
    // Number of samples
    ts.setGenotypeMatrix(Utils.tokenize("genotype -n -1 -f 'DP > 100'", " "));
    System.err.println(ts.getTrack(t1).printToScreen());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 57 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackTest method canPrintBamWithClippedSeq.

@Test
public void canPrintBamWithClippedSeq() throws InvalidGenomicCoordsException, IOException, InvalidColourException, InvalidCommandLineException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidConfigException {
    new Config(null);
    GenomicCoords gc = new GenomicCoords("chr7:5566733-5566903", 160, null, null);
    TrackReads tif = new TrackReads("test_data/ds051.actb.bam", gc);
    tif.setNoFormat(true);
    tif.setPrintMode(PrintRawLine.CLIP);
    assertTrue(tif.printLines().contains(" CTCAT[+"));
    assertTrue(tif.printLines().contains(" CCCFF[+"));
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Config(coloring.Config) Test(org.junit.Test)

Example 58 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackTest method printIsNotResetAfterExec.

@Test
public void printIsNotResetAfterExec() throws InvalidGenomicCoordsException, IOException, InvalidColourException, InvalidCommandLineException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidConfigException {
    new Config(null);
    // BAM
    GenomicCoords gc = new GenomicCoords("chr7:5566733-5566903", 80, null, null);
    TrackReads tif = new TrackReads("test_data/ds051.short.bam", gc);
    tif.setNoFormat(true);
    tif.setPrintMode(PrintRawLine.FULL);
    tif.setSystemCommandForPrint("grep NCNNTCCC");
    assertEquals(2, tif.printLines().split("\n").length);
    // Call printLines again on new coordinates:
    // The sys command is still on
    gc = new GenomicCoords("chr7:5566733-5566904", 80, null, null);
    tif.setGc(gc);
    System.err.println(tif.printLines());
    assertEquals(2, tif.printLines().split("\n").length);
    // Now turn it off:
    tif.setSystemCommandForPrint("");
    assertEquals(22, tif.printLines().split("\n").length);
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Config(coloring.Config) Test(org.junit.Test)

Example 59 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackTest method canParsePrintableLinesWithSystemCommand.

@Test
public void canParsePrintableLinesWithSystemCommand() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, InvalidCommandLineException {
    GenomicCoords gc = new GenomicCoords("chr1:1-100000", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature("test_data/hg19_genes_head.gtf", gc);
    tif.setNoFormat(true);
    tif.setPrintMode(PrintRawLine.FULL);
    tif.setSystemCommandForPrint("grep WASH7P | sort -k5,5nr");
    String out = tif.printLines();
    // Same as `awk '$4 <= 100000' hg19_genes_head.gtf | grep WASH7P | sort -k5,5nr | wc -l`
    // 11 lines grepped.
    assertEquals(11, Splitter.on("\n").omitEmptyStrings().splitToList(out).size());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Test(org.junit.Test)

Example 60 with GenomicCoords

use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.

the class TrackTest method canConcatTitleAndTrack.

// @Test
// public void canSetVariantReadsFilterBasedOnScreenPercent() throws InvalidCommandLineException, InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException{
// 
// GenomicCoords gc= new GenomicCoords("chr7:3-101", 1000, null, "test_data/chr7.fa");
// 
// Track t1= new TrackReads("test_data/ds051.actb.bam", gc);
// 
// t1.setVariantReadInInterval("0.0", true);
// assertEquals(3, t1.getFeatureFilter().getVariantFrom());
// assertEquals(3, t1.getFeatureFilter().getVariantTo());
// 
// t1.setVariantReadInInterval("1.0", true);
// assertEquals(101, t1.getFeatureFilter().getVariantFrom());
// assertEquals(101, t1.getFeatureFilter().getVariantTo());
// 
// //     (101-3+1) * 0.5 = 49.5
// // We round to 49.5 to 50. So:
// //     3 + 50 - 1 = 52
// t1.setVariantReadInInterval("0.5", true);
// assertEquals(52, t1.getFeatureFilter().getVariantFrom());
// 
// gc= new GenomicCoords("chr7:3-102", 1000, null, "test_data/chr7.fa");
// t1= new TrackReads("test_data/ds051.actb.bam", gc);
// t1.setVariantReadInInterval("0.5", true);
// assertEquals(52, t1.getFeatureFilter().getVariantFrom());
// 
// // Must fail
// boolean pass= false;
// try{
// t1.setVariantReadInInterval("foo", true);
// } catch(NumberFormatException e){
// pass= true;
// }
// assertTrue(pass);
// }
@Test
public void canConcatTitleAndTrack() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidConfigException, InvalidColourException {
    new Config(null);
    GenomicCoords gc = new GenomicCoords("1:735171-2045891", 80, null, null);
    TrackIntervalFeature tif = new TrackIntervalFeature("test_data/CHD.exon.2010_03.sites.vcf", gc);
    tif.setNoFormat(true);
    tif.setTrackTag("title.bed");
    String[] lines = tif.concatTitleAndTrack().split("\n");
    assertEquals(3, lines.length);
    assertTrue(lines[0].startsWith("title.bed"));
    assertTrue(lines[0].trim().endsWith("A"));
    System.err.println(tif.concatTitleAndTrack());
    // Do not put on different lines
    tif.setTrackTag("LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongTitle.bed");
    lines = tif.concatTitleAndTrack().split("\n");
    assertEquals(4, lines.length);
    System.err.println(tif.concatTitleAndTrack());
}
Also used : GenomicCoords(samTextViewer.GenomicCoords) Config(coloring.Config) 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