Search in sources :

Example 1 with Config

use of coloring.Config in project ASCIIGenome by dariober.

the class TrackProcessorTest method canProcessTracks.

@Test
public void canProcessTracks() throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, BamIndexNotFoundException, InvalidRecordException, SQLException, InvalidConfigException, InvalidCommandLineException, DocumentException, InvalidColourException {
    new Config(null);
    GenomicCoords gc = new GenomicCoords("chr7:1-100", 80, null, null);
    List<String> genome = new ArrayList<String>();
    genome.add("test_data/ear045.oxBS.actb.bam");
    gc.setGenome(genome, true);
    GenomicCoordsHistory gch = new GenomicCoordsHistory();
    gch.add(gc);
    TrackSet trackSet = new TrackSet();
    trackSet.addTrackFromSource("test_data/hg19_genes.gtf.gz", gc, null);
    trackSet.addTrackFromSource("test_data/ear045.oxBS.actb.bam", gc, null);
    trackSet.addTrackFromSource("test_data/ear045.oxBS.actb.tdf", gc, null);
    TrackProcessor tp = new TrackProcessor(trackSet, gch);
// tp.iterateTracks();
}
Also used : TrackSet(tracks.TrackSet) Config(coloring.Config) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with Config

use of coloring.Config 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)

Example 3 with Config

use of coloring.Config 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 4 with Config

use of coloring.Config 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 5 with Config

use of coloring.Config 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

Config (coloring.Config)11 Test (org.junit.Test)9 GenomicCoords (samTextViewer.GenomicCoords)8 ArrayList (java.util.ArrayList)4 TrackSet (tracks.TrackSet)2 ConfigKey (coloring.ConfigKey)1 Xterm256 (coloring.Xterm256)1 InvalidColourException (exceptions.InvalidColourException)1 InvalidCommandLineException (exceptions.InvalidCommandLineException)1 InvalidConfigException (exceptions.InvalidConfigException)1 InvalidGenomicCoordsException (exceptions.InvalidGenomicCoordsException)1 InvalidRecordException (exceptions.InvalidRecordException)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 ConsoleReader (jline.console.ConsoleReader)1 ArgumentParserException (net.sourceforge.argparse4j.inf.ArgumentParserException)1 Namespace (net.sourceforge.argparse4j.inf.Namespace)1 IntervalFeature (tracks.IntervalFeature)1