Beispiel #1
0
 def testCase(self, instance):
     data = TokenReader(StringIO(" ".join(instance)))
     dataset = TestDataset.loadStructure(data)
     disjointigs = DisjointigCollection()
     for dis in dataset.disjointigs:
         disjointigs.addNew(dis.seq, dis.id)
     dp = DotPlot(disjointigs)
     dp.construct(self.aligner)
     save = StringIO()
     save_handler = TokenWriter(save)
     dp.save(save_handler)
     tmp = save.getvalue()
     test_result = tmp.replace(" ", "").replace("\n", "")
     ethalon = data.readToken()
     if test_result != ethalon:
         for dis in disjointigs:
             print list(dp.allInter(dis.asSegment()))
     assert test_result == ethalon, "\n" + test_result + "\n" + ethalon
 def genAll(self, aligner):
     # type: (Aligner) -> Tuple[NewLineStorage, LineDotPlot, ReadCollection]
     disjointigs = DisjointigCollection()
     for dis in self.disjointigs:
         disjointigs.addNew(dis.seq, dis.id)
     from disjointig_resolve.line_storage import NewLineStorage
     lines = NewLineStorage(disjointigs, aligner)
     lines.name_printer = lambda line: line.id + "_" + self.translateBack(
         line, aligner)
     for line in self.contigs:
         new_line = lines.addNew(line.seq, line.id)
         new_line.initial.add(
             AlignmentPiece.Identical(
                 new_line.asSegment().asContig().asSegment(),
                 new_line.asSegment()))
     dp = LineDotPlot(lines, aligner)
     dp.construct(aligner)
     lines.alignDisjointigs()
     reads = ReadCollection()
     for read in self.reads:
         reads.addNewRead(read)
     disjointigs.addAlignments(aligner.localAlign(reads, disjointigs))
     return lines, dp, reads