示例#1
0
 def loadFromFasta(self,
                   handler,
                   save_names=False,
                   int_ids=False,
                   filter=lambda rec: True):
     # type: (BinaryIO, bool, bool, Callable[[NamedSequence], bool]) -> DisjointigCollection
     recs = list(SeqIO.parse_fasta(handler))
     if save_names:
         for rec in recs:
             assert rec.id not in self.items.keys() and basic.Reverse(
                 rec.id) not in self.items.keys()
     for rec in recs:
         if not filter(rec):
             continue
         if save_names:
             number = basic.parseNegativeNumber(rec.id)
             if number is not None:
                 self.cnt = max(self.cnt, int(abs(number)) + 1)
             if int_ids:
                 self.addNew(rec.seq, str(number))
             else:
                 self.addNew(rec.seq)
         else:
             self.addNew(rec.seq)
     return self
示例#2
0
def EACL(aligner, cl_params, contigs, disjointigs, dot_plot, extender, lines, reads, save_handler):
    cnt = 0
    stop = False
    while not stop:
        stop = True
        if cl_params.focus is None:
            keys = list(lines.items.keys())
        else:
            keys = cl_params.focus
        for line_id in keys:
            if line_id not in lines.items:
                if cl_params.focus is None:
                    continue
                else:
                    for key in lines.items.keys():
                        if str(basic.parseNegativeNumber(basic.parseLineName(key)[-1])) == line_id and lines[key].knot is None:
                            line_id = key
                            break
                    if line_id not in lines.items.keys():
                        continue
            line = lines[line_id]
            sys.stdout.info("Investigating", line)
            extended = extender.processLine(line)
            if extended > 0:
                cnt += 1
                stop = False
            if cnt > 10:
                cnt = 0
                if save_handler is not None:
                    printState(lines)
                    sys.stdout.trace( "Saving current state")
                    writer = save_handler.getWriter()
                    sys.stdout.trace( "Save details:", writer.info)
                    saveAll(writer, cl_params, aligner, contigs, reads, disjointigs, lines, dot_plot)
示例#3
0
 def parse(self, edge_ids=None):
     # type: (Optional[Dict[int, List[str]]]) -> Generator[Tuple[int, int, int, int, EdgeInfo]]
     for s in self.dot.readlines():
         if s.find("->") == -1:
             continue
         v_from = basic.parseNumber(s)
         v_to = basic.parseNumber(s, s.find("->"))
         eid = basic.parseNegativeNumber(s, s.find("id"))
         len = basic.parseNegativeNumber(s, s.find("\\l"))
         cov = basic.parseNumber(s, s.find("k "))
         unique = (s.find("black") != -1)
         src = (s.find("dir = both") != -1)
         if edge_ids is None or eid in edge_ids:
             if edge_ids is not None:
                 if "sink" in edge_ids[eid]:
                     v_to = "sink"
                 if "source" in edge_ids[eid]:
                     v_from = "source"
             yield eid, v_from, v_to, cov, EdgeInfo(s, unique, cov, len,
                                                    src)