def addFinishCap(self, graph): if self.softFinish is not None: self.finishCap = Breakend(self.chr, self.softFinish, False, self.name + ":finish", finish=self.finish) else: self.finishCap = Breakend(self.chr, self.finish - 1, False, self.name + ":finish", finish=self.finish) self.finishCap.createPartner(graph) assert self.val >= 0 self.finishCap.segment = self.val graph.addBreakend(self.finishCap)
def parseBreaksLineNew(line, breakends): items = line.strip().split() if float(items[8]) < 0: return coords = items[0].split(':') chr = coords[0] if chr[:3] != "chr": chr = "chr" + chr pos = map(int, coords[1].split('-')) breakend = Breakend(chr, min(pos), items[2] == '-', "BND" + str(len(breakends)) + ":" + items[0] + ":" + items[1], finish=max(pos)) breakend.mates = [None] coords2 = items[1].split(':') chr2 = coords2[0] if chr2[:3] != "chr": chr2 = "chr" + chr2 pos2 = map(int, coords2[1].split('-')) breakend.remoteChr = [chr2] breakend.remoteStart = [min(pos2)] breakend.remoteFinish = [max(pos2)] breakend.remoteOrientation = [items[3] == '-'] breakend.adjacency_cov = [-1, float(items[5])] breakend.germline = (items[4] == 'germline') breakends.append(breakend)
def parseBreaksLine(line, breakends): items = line.strip().split() if float(items[11]) < 0: return if items[0][:3] != "chr": items[0] = "chr" + items[0] breakend = Breakend(items[0], items[1], items[3] == '-', "BND" + str(len(breakends)) + ":" + items[0] + ":" + items[1] + items[3] + ">>" + items[4] + ":" + items[5] + items[7], finish=int(items[2])) breakend.mates = [None] if items[4][:3] != "chr": items[4] = "chr" + items[4] breakend.remoteChr = [items[4]] breakend.remoteStart = [int(items[5])] breakend.remoteFinish = [int(items[6])] breakend.remoteOrientation = [items[7] == '-'] breakend.germline = (items[8] == 'GERMLINE') breakend.adjacency_cov = [-1, float(items[9])] breakends.append(breakend)
def parseBreaksLineTabbed(line, breakends): items = line.strip().split() if float(items[8]) < 0: assert False return chr = items[0] if chr[:3] != "chr": chr = "chr" + chr leftCoords = chr + ":" + items[4] + "-" + items[5] chr2 = items[6] if chr2[:3] != "chr": chr2 = "chr" + chr2 rightCoords = chr2 + ":" + items[7] + "-" + items[8] breakend = Breakend(chr, int(items[4]), items[9] == '-', "BND" + str(len(breakends)) + ":" + leftCoords + ":" + rightCoords, finish=int(items[5])) breakend.mates = [None] breakend.remoteChr = [chr2] breakend.remoteStart = [int(items[7])] breakend.remoteFinish = [int(items[8])] breakend.remoteOrientation = [items[10] == '-'] breakend.adjacency_cov = [-1, float(items[11])] breakend.germline = False breakends.append(breakend)
class CNV(coords.Region): """ CNV data holder""" def __init__(self, chr, start, finish, val, name, softStart=None, softFinish=None): super(CNV, self).__init__(chr, start, finish) self.val = list(val) self.softStart = softStart self.softFinish = softFinish self.startCap = None self.finishCap = None self.name = str(name) def __str__(self): if self.softStart is None or self.softFinish is None: return "[%s] %s:%i-%i=%s" % (self.name, self.chr, self.start, self.finish, str(self.val)) else: return "[%s] %s:%i/%li-%i/%li=%s" % (self.name, self.chr, self.start, self.softStart, self.softFinish, self.finish, str(self.val)) def addStartCap(self, graph): self.startCap = Breakend(self.chr, self.start, True, self.name + ":start", finish=self.softStart) self.startCap.createPartner(graph) assert self.val >= 0 self.startCap.segment = self.val graph.addBreakend(self.startCap) def addFinishCap(self, graph): if self.softFinish is not None: self.finishCap = Breakend(self.chr, self.softFinish, False, self.name + ":finish", finish=self.finish) else: self.finishCap = Breakend(self.chr, self.finish - 1, False, self.name + ":finish", finish=self.finish) self.finishCap.createPartner(graph) assert self.val >= 0 self.finishCap.segment = self.val graph.addBreakend(self.finishCap) def validate(self): super(CNV, self).validate() if self.softStart is not None: assert self.softStart >= self.start assert self.softStart <= self.finish if self.softFinish is not None: assert self.softFinish >= self.start assert self.softFinish <= self.finish if self.softStart is not None and self.softFinish is not None: assert self.softFinish >= self.softStart return True def ploidy(self): return len(self.val)
def addStartCap(self, graph): self.startCap = Breakend(self.chr, self.start, True, self.name + ":start", finish=self.softStart) self.startCap.createPartner(graph) assert self.val >= 0 self.startCap.segment = self.val graph.addBreakend(self.startCap)