last-dotplot: implementing annotation names...
authorMartin C. Frith
Fri Jul 31 14:36:00 2020 +0900 (11 days ago)
changeset 1074170ab6c64728
parent 1073 8ec299b42e28
child 1075 70b0e512d696
last-dotplot: implementing annotation names...
scripts/last-dotplot
     1.1 --- a/scripts/last-dotplot	Fri Jul 31 14:18:38 2020 +0900
     1.2 +++ b/scripts/last-dotplot	Fri Jul 31 14:36:00 2020 +0900
     1.3 @@ -593,6 +593,7 @@
     1.4          end = int(w[2])
     1.5          if all(beg >= i[2] or end <= i[1] for i in seqRanges):
     1.6              continue
     1.7 +        itemName = w[3] if len(w) > 3 and w[3] != "." else ""
     1.8          layer = 900
     1.9          color = "#fbf"
    1.10          if len(w) > 4:
    1.11 @@ -608,15 +609,16 @@
    1.12                          color = "#ffe8e8"
    1.13                      if strand == "-" and not isRev or strand == "+" and isRev:
    1.14                          color = "#e8e8ff"
    1.15 -        yield layer, color, seqName, beg, end
    1.16 +        yield layer, color, seqName, beg, end, itemName
    1.17  
    1.18  def commaSeparatedInts(text):
    1.19      return map(int, text.rstrip(",").split(","))
    1.20  
    1.21  def readGenePred(opts, fileName, rangeDict):
    1.22      for line in myOpen(fileName):
    1.23 -        fields = line.split()
    1.24 +        fields = line.split()  # xxx tab ???
    1.25          if not fields: continue
    1.26 +        geneName = fields[12 if len(fields) > 12 else 0]  # XXX ???
    1.27          if fields[2] not in "+-":
    1.28              fields = fields[1:]
    1.29          seqName = fields[1]
    1.30 @@ -630,10 +632,10 @@
    1.31          for beg, end in zip(exonBegs, exonEnds):
    1.32              if all(beg >= i[2] or end <= i[1] for i in seqRanges):
    1.33                  continue
    1.34 -            yield 300, opts.exon_color, seqName, beg, end
    1.35 +            yield 300, opts.exon_color, seqName, beg, end, geneName
    1.36              b = max(beg, cdsBeg)
    1.37              e = min(end, cdsEnd)
    1.38 -            if b < e: yield 400, opts.cds_color, seqName, b, e
    1.39 +            if b < e: yield 400, opts.cds_color, seqName, b, e, ""
    1.40  
    1.41  def readRmsk(fileName, rangeDict):
    1.42      for line in myOpen(fileName):
    1.43 @@ -644,6 +646,7 @@
    1.44              beg = int(fields[6])
    1.45              end = int(fields[7])
    1.46              strand = fields[9]
    1.47 +            repeatName = fields[10]
    1.48              repeatClass = fields[11]
    1.49          elif len(fields) == 15:  # .out
    1.50              seqName = fields[4]
    1.51 @@ -651,6 +654,7 @@
    1.52              beg = int(fields[5]) - 1
    1.53              end = int(fields[6])
    1.54              strand = fields[8]
    1.55 +            repeatName = fields[9]
    1.56              repeatClass = fields[10].split("/")[0]
    1.57          else:
    1.58              continue
    1.59 @@ -658,11 +662,11 @@
    1.60          if all(beg >= i[2] or end <= i[1] for i in seqRanges):
    1.61              continue
    1.62          if repeatClass in ("Low_complexity", "Simple_repeat", "Satellite"):
    1.63 -            yield 200, "#fbf", seqName, beg, end
    1.64 +            yield 200, "#fbf", seqName, beg, end, repeatName
    1.65          elif (strand == "+") != (seqRanges[0][3] > 1):
    1.66 -            yield 100, "#ffe8e8", seqName, beg, end
    1.67 +            yield 100, "#ffe8e8", seqName, beg, end, repeatName
    1.68          else:
    1.69 -            yield 100, "#e8e8ff", seqName, beg, end
    1.70 +            yield 100, "#e8e8ff", seqName, beg, end, repeatName
    1.71  
    1.72  def isExtraFirstGapField(fields):
    1.73      return fields[4].isdigit()
    1.74 @@ -679,12 +683,12 @@
    1.75          end = int(w[2])
    1.76          beg = end - int(w[5])  # zero-based coordinate
    1.77          if w[7] == "yes":
    1.78 -            yield 3000, opts.bridged_color, seqName, beg, end
    1.79 +            yield 3000, opts.bridged_color, seqName, beg, end, ""
    1.80          else:
    1.81 -            yield 2000, opts.unbridged_color, seqName, beg, end
    1.82 +            yield 2000, opts.unbridged_color, seqName, beg, end, ""
    1.83  
    1.84  def bedBoxes(beds, rangeDict, margin, edge, isTop, bpPerPix):
    1.85 -    for layer, color, seqName, bedBeg, bedEnd in beds:
    1.86 +    for layer, color, seqName, bedBeg, bedEnd, name in beds:
    1.87          for rangeBeg, rangeEnd, isReverseRange, origin in rangeDict[seqName]:
    1.88              beg = max(bedBeg, rangeBeg)
    1.89              end = min(bedEnd, rangeEnd)