/** Test of processNextStart method, of class Overlap. */
  @Test
  public void testProcessNextStart() throws IOException {
    System.out.println("Tabix Test!");

    // Example direct tabix query and the results... (note only the JSON will be returned by the
    // overlapPipe)
    // r0240560:tabix m102417$ tabix genes.tsv.bgz 17:41196312-41300000
    // 17	41196312	41277500
    //	{"_type":"gene","_landmark":"17","_strand":"-","_minBP":41196312,"_maxBP":41277500,"gene":"BRCA1","gene_synonym":"BRCAI; BRCC1; BROVCA1; IRIS; PNCA4; PPP1R53; PSCP; RNF53","note":"breast cancer 1, early onset; Derived by automated computational analysis using gene prediction method: BestRefseq.","GeneID":"672","HGNC":"1100","HPRD":"00218","MIM":"113705"}
    // 17	41231278	41231833
    //	{"_type":"gene","_landmark":"17","_strand":"+","_minBP":41231278,"_maxBP":41231833,"gene":"RPL21P4","gene_synonym":"RPL21_58_1548","note":"ribosomal protein L21 pseudogene 4; Derived by automated computational analysis using gene prediction method: Curated Genomic.","pseudo":"","GeneID":"140660","HGNC":"17959"}
    // 17	41277600	41297130
    //	{"_type":"gene","_landmark":"17","_strand":"+","_minBP":41277600,"_maxBP":41297130,"gene":"NBR2","gene_synonym":"NCRNA00192","note":"neighbor of BRCA1 gene 2 (non-protein coding); Derived by automated computational analysis using gene prediction method: BestRefseq.","GeneID":"10230","HGNC":"20691"}
    // 17	41286808	41287385
    //	{"_type":"gene","_landmark":"17","_strand":"+","_minBP":41286808,"_maxBP":41287385,"gene":"LOC100505873","note":"Derived by automated computational analysis using gene prediction method: GNOMON. Supporting evidence includes similarity to: 1 EST, 1 Protein","pseudo":"","GeneID":"100505873"}
    // 17	41296973	41297272
    //	{"_type":"gene","_landmark":"17","_strand":"+","_minBP":41296973,"_maxBP":41297272,"gene":"HMGN1P29","note":"high mobility group nucleosome binding domain 1 pseudogene 29; Derived by automated computational analysis using gene prediction method: Curated Genomic.","pseudo":"","GeneID":"100885865","HGNC":"39373"}
    // String query =
    // "my\tfirst\tquery\t{\"_landmark\":\"17\",\"_minBP\":41196312,\"_maxBP\":41277500}";  //1
    // result
    String query2 =
        "my\tfirst\tquery\t{\"_landmark\":\"17\",\"_minBP\":41196312,\"_maxBP\":41300000}"; // 5
                                                                                            // results

    List<History> result = new ArrayList<History>();
    OverlapPipe op = new OverlapPipe(geneFile);
    Pipe<String, History> p2 = new Pipeline<String, History>(new HistoryInPipe(), op);
    p2.setStarts(Arrays.asList(query2));
    while (p2.hasNext()) {
      result.add(p2.next());
    }

    assertEquals(5, result.size()); // 5 rows returned
    // System.out.println(result.get(4)); //5 rows returned
  }
  @Test
  public void testProcessNextStart_OneResult() throws IOException {
    System.out.println("Tabix Test.. TWO RESULTS!");

    // Example direct tabix query and the results... (note only the JSON will be returned by the
    // overlapPipe)
    // r0240560:tabix m102417$ tabix genes.tsv.bgz 17:41196312-41300000
    // 17	41196312	41277500
    //	{"_type":"gene","_landmark":"17","_strand":"-","_minBP":41196312,"_maxBP":41277500,"gene":"BRCA1","gene_synonym":"BRCAI; BRCC1; BROVCA1; IRIS; PNCA4; PPP1R53; PSCP; RNF53","note":"breast cancer 1, early onset; Derived by automated computational analysis using gene prediction method: BestRefseq.","GeneID":"672","HGNC":"1100","HPRD":"00218","MIM":"113705"}
    // {"_type":"gene","_landmark":"17","_strand":"+","_minBP":41231278,"_maxBP":41231833,"gene":"RPL21P4","gene_synonym":"RPL21_58_1548","note":"ribosomal protein L21 pseudogene 4; Derived by automated computational analysis using gene prediction method: Curated Genomic.","pseudo":"","GeneID":"140660","HGNC":"17959"}

    // TODO find a query that returns exactly 1 row
    String query =
        "my\tfirst\tquery\t{\"_landmark\":\"17\",\"_minBP\":41196312,\"_maxBP\":41277500}"; // 2
                                                                                            // results

    List<History> result = new ArrayList<History>();
    OverlapPipe op = new OverlapPipe(geneFile);
    Pipe<String, History> p2 = new Pipeline<String, History>(new HistoryInPipe(), op);
    p2.setStarts(Arrays.asList(query));
    while (p2.hasNext()) {
      result.add(p2.next());
    }
    // System.out.println("size="+result.size());
    assertEquals(2, result.size()); // two result
  }
 @Test
 public void testBRCA1DOWN() throws IOException {
   System.out.println("Get the genes down-chromosome and including BRCA1");
   String[] paths = {"gene"};
   String query = "x\ty\tz\t" + BRCA1;
   OverlapPipe op = new OverlapPipe(geneFile, 0, 19772);
   Pipe p = new Pipeline(new HistoryInPipe(), op, new DrillPipe(false, paths), new PrintPipe());
   p.setStarts(Arrays.asList(query));
   for (int i = 1; p.hasNext(); i++) {
     History h = (History) p.next();
     if (i == 1) {
       assertEquals("BRCA1", h.get(4));
     }
     if (i == 2) {
       assertEquals("RPL21P4", h.get(4)); // gene overlaps BRCA1 so it is included
     }
     if (i == 3) {
       assertEquals("NBR2", h.get(4));
     }
     if (i == 4) {
       assertEquals("LOC100505873", h.get(4));
     }
     if (i == 5) {
       assertEquals("HMGN1P29", h.get(4));
     }
   }
 }
 @Test
 public void testGetCluster() throws IOException {
   System.out.println("Get all the genes around BRCA1");
   String[] paths = {"gene"};
   String query = "x\ty\tz\t{\"_landmark\":\"17\",\"_minBP\":41166622,\"_maxBP\":41297272}";
   OverlapPipe op = new OverlapPipe(geneFile, 0, 0);
   Pipe p = new Pipeline(new HistoryInPipe(), op, new DrillPipe(false, paths), new PrintPipe());
   p.setStarts(Arrays.asList(query));
   for (int i = 1; p.hasNext(); i++) {
     History h = (History) p.next();
     if (i == 1) {
       assertEquals("VAT1", h.get(4));
     }
     if (i == 2) {
       assertEquals("RND2", h.get(4));
     }
     if (i == 3) {
       assertEquals("BRCA1", h.get(4));
     }
     if (i == 4) {
       assertEquals("RPL21P4", h.get(4));
     }
     if (i == 5) {
       assertEquals("NBR2", h.get(4));
     }
     if (i == 6) {
       assertEquals("LOC100505873", h.get(4));
     }
     if (i == 7) {
       assertEquals("HMGN1P29", h.get(4));
     }
   }
 }
Example #5
0
  public S processNextStart() {
    final S s = this.starts.next();
    this.pipe.setStarts(new SingleIterator<S>(s));

    try {
      while (true) {
        pipe.next();
      }
    } catch (final NoSuchElementException e) {
    }
    return s;
  }
  // make sure to test zero results!!!
  @Test
  public void testProcessNextStart_ZeroResults() throws Exception {
    System.out.println("Tabix Test.. Zero Results!");

    String query =
        "my\tfirst\tquery\t{\"_landmark\":\"17\",\"_minBP\":4,\"_maxBP\":41}"; // 1 result

    try {
      List<History> result = new ArrayList<History>();
      OverlapPipe op = new OverlapPipe(geneFile);
      Pipe<String, History> p2 = new Pipeline<String, History>(new HistoryInPipe(), op);
      p2.setStarts(Arrays.asList(query));
      // assertTrue(p.hasNext()==false);
      for (int i = 0; p2.hasNext(); i++) {
        p2.next();
      }
    } catch (Exception e) {
      Assert.fail("INVALID QUERY... EXPECTED EXCEPTION!!!");
    }
  }
  /**
   * 1 49482 rs202079915 G A . .
   * RSPOS=49482;dbSNPBuildID=137;SSR=0;SAO=0;VP=050000000005000002000100;WGT=1;VC=SNV;ASP;OTHERK{"CHROM":"1","POS":"49482","ID":"rs202079915","REF":"G","ALT":"A","QUAL":".","FILTER":".","INFO":{"RSPOS":49482,"dbSNPBuildID":137,"SSR":0,"SAO":0,"VP":"050000000005000002000100","WGT":1,"VC":"SNV","ASP":true,"OTHERKG":true},"_id":"rs202079915","_type":"variant","_landmark":"1","_refAllele":"G","_altAlleles":["A"],"_minBP":49482,"_maxBP":49482}
   * {}
   */
  @Test
  public void testProcessNextStart_ZeroResultsEmptyJson() throws Exception {
    System.out.println("Tabix Test.. Zero Results.. with Empty JSON!");

    String query =
        "my\tfirst\tquery\t{\"_landmark\":\"1\",\"_minBP\":49482,\"_maxBP\":49482}"; // 1 result

    try {
      List<History> result = new ArrayList<History>();
      OverlapPipe op = new OverlapPipe(geneFile);
      Pipe<String, History> p2 = new Pipeline<String, History>(new HistoryInPipe(), op);
      p2.setStarts(Arrays.asList(query));
      // assertTrue(p.hasNext()==false);
      for (int i = 0; p2.hasNext(); i++) {
        result.add(p2.next());
      }
      // System.out.println(result.size());
      assertEquals("{}", result.get(4)); // EMPTY JSON as last element in the list
    } catch (Exception e) {
      // Assert.fail("INVALID QUERY... EXPECTED EXCEPTION!!!");
    }
  }
Example #8
0
 public void testIdEdgePipeGraph() {
   Graph graph = TinkerGraphFactory.createTinkerGraph();
   List<String> ids = Arrays.asList("9", "11", "12");
   Pipe<String, Edge> pipe = new IdEdgePipe<String>(graph);
   pipe.setStarts(ids);
   int counter = 0;
   while (pipe.hasNext()) {
     Edge edge = pipe.next();
     if (counter == 0) {
       assertEquals(edge.getId(), "9");
       assertEquals(edge.getProperty("weight"), 0.4f);
     } else if (counter == 1) {
       assertEquals(edge.getId(), "11");
       assertEquals(edge.getInVertex(), graph.getVertex("3"));
     } else if (counter == 2) {
       assertEquals(edge.getId(), "12");
       assertEquals(edge.getLabel(), "created");
     } else {
       throw new RuntimeException("Illegal state.");
     }
     counter++;
   }
   assertEquals(counter, 3);
 }
 @Test
 public void extractSequencePipeline() throws IOException {
   System.out.println("Extract Sequence Pipeline Test.");
   Pipe p = new Pipeline(new HistoryInPipe(), new Bed2SequencePipe(tabixGenome));
   p.setStarts(Arrays.asList(p1, p2, p3, p4, p5));
   for (int i = 0; p.hasNext(); i++) {
     ArrayList al = (ArrayList) p.next();
     if (i == 0) {
       assertEquals("G", al.get(3));
     }
     if (i == 1) {
       assertEquals("G", al.get(3));
     }
     if (i == 2) {
       assertEquals("T", al.get(3));
     }
     if (i == 3) {
       assertEquals("C", al.get(3));
     }
     if (i == 4) {
       assertEquals("G", al.get(3));
     }
   }
 }