scripts/last-postmask
changeset 863 6a4915d5b5cb
parent 480 aec8ba9a675a
child 867 f9ec9c71d72e
     1.1 --- a/scripts/last-postmask	Wed Sep 24 15:31:39 2014 +0900
     1.2 +++ b/scripts/last-postmask	Fri Jun 02 18:40:29 2017 +0900
     1.3 @@ -12,7 +12,7 @@
     1.4  # Limitations: doesn't (yet) handle sequence quality data,
     1.5  # frameshifts, or generalized affine gaps.
     1.6  
     1.7 -import fileinput, itertools, optparse, os, signal, sys
     1.8 +import itertools, optparse, os, signal, sys
     1.9  
    1.10  def getScoreMatrix(rowHeads, colHeads, matrix, deleteCost, insertCost):
    1.11      defaultScore = min(map(min, matrix))
    1.12 @@ -56,12 +56,12 @@
    1.13              print line,
    1.14          print
    1.15  
    1.16 -def lastPostmask(args):
    1.17 +def doOneFile(file):
    1.18      scoreMatrix = []
    1.19      maf = []
    1.20      seqs = []
    1.21  
    1.22 -    for line in fileinput.input(args):
    1.23 +    for line in file:
    1.24          if line[0] == "#":
    1.25              print line,
    1.26              w = line.split()
    1.27 @@ -90,6 +90,17 @@
    1.28              if line[0] == "s": seqs.append(line.split()[6])
    1.29      if seqs: printIfGood(maf, seqs, scoreMatrix, aDel, aIns, minScore)
    1.30  
    1.31 +def lastPostmask(args):
    1.32 +    if args:
    1.33 +        for i in args:
    1.34 +            if i == "-":
    1.35 +                doOneFile(sys.stdin)
    1.36 +            else:
    1.37 +                with open(i) as file:
    1.38 +                    doOneFile(file)
    1.39 +    else:
    1.40 +        doOneFile(sys.stdin)
    1.41 +
    1.42  if __name__ == "__main__":
    1.43      signal.signal(signal.SIGPIPE, signal.SIG_DFL)  # avoid silly error message
    1.44