annotate extractSplitReads_BwaMem.py @ 0:a1225091082c draft

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
author artbio
date Mon, 14 Oct 2019 07:11:39 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
1 #!/usr/bin/env python
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
2
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
3 import re
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
4 import sys
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
5 from optparse import OptionParser
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
6
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
7
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
8 def extractSplitsFromBwaMem(inFile, numSplits, includeDups, minNonOverlap):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
9 if inFile == "stdin":
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
10 data = sys.stdin
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
11 else:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
12 data = open(inFile, 'r')
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
13 for line in data:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
14 split = 0
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
15 if line[0] == '@':
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
16 print(line.strip())
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
17 continue
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
18 samList = line.strip().split('\t')
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
19 sam = SAM(samList)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
20 if includeDups == 0 and (1024 & sam.flag) == 1024:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
21 continue
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
22 for el in sam.tags:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
23 if "SA:" in el:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
24 if(len(el.split(";"))) <= numSplits:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
25 split = 1
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
26 mate = el.split(",")
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
27 mateCigar = mate[3]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
28 mateFlag = int(0)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
29 if mate[2] == "-":
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
30 mateFlag = int(16)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
31 if split:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
32 read1 = sam.flag & 64
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
33 if read1 == 64:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
34 tag = "_1"
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
35 else:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
36 tag = "_2"
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
37 samList[0] = sam.query + tag
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
38 readCigar = sam.cigar
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
39 readCigarOps = extractCigarOps(readCigar, sam.flag)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
40 readQueryPos = calcQueryPosFromCigar(readCigarOps)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
41 mateCigarOps = extractCigarOps(mateCigar, mateFlag)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
42 mateQueryPos = calcQueryPosFromCigar(mateCigarOps)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
43 overlap = calcQueryOverlap(readQueryPos.qsPos, readQueryPos.qePos,
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
44 mateQueryPos.qsPos, mateQueryPos.qePos)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
45 nonOverlap1 = 1 + readQueryPos.qePos - readQueryPos.qsPos - overlap
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
46 nonOverlap2 = 1 + mateQueryPos.qePos - mateQueryPos.qsPos - overlap
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
47 mno = min(nonOverlap1, nonOverlap2)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
48 if mno >= minNonOverlap:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
49 print("\t".join(samList))
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
50
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
51 # -----------------------------------------------------------------------
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
52 # functions
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
53 # -----------------------------------------------------------------------
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
54
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
55
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
56 class SAM (object):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
57 """
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
58 __very__ basic class for SAM input.
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
59 """
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
60 def __init__(self, samList=[]):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
61 if len(samList) > 0:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
62 self.query = samList[0]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
63 self.flag = int(samList[1])
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
64 self.ref = samList[2]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
65 self.pos = int(samList[3])
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
66 self.mapq = int(samList[4])
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
67 self.cigar = samList[5]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
68 self.matRef = samList[6]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
69 self.matePos = int(samList[7])
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
70 self.iSize = int(samList[8])
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
71 self.seq = samList[9]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
72 self.qual = samList[10]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
73 self.tags = samList[11:]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
74 # tags is a list of each tag:vtype:value sets
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
75 self.valid = 1
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
76 else:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
77 self.valid = 0
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
78 self.query = 'null'
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
79
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
80 def extractTagValue(self, tagID):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
81 for tag in self.tags:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
82 tagParts = tag.split(':', 2)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
83 if (tagParts[0] == tagID):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
84 if (tagParts[1] == 'i'):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
85 return int(tagParts[2])
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
86 elif (tagParts[1] == 'H'):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
87 return int(tagParts[2], 16)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
88 return tagParts[2]
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
89 return None
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
90
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
91
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
92 cigarPattern = '([0-9]+[MIDNSHP])'
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
93 cigarSearch = re.compile(cigarPattern)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
94 atomicCigarPattern = '([0-9]+)([MIDNSHP])'
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
95 atomicCigarSearch = re.compile(atomicCigarPattern)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
96
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
97
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
98 def extractCigarOps(cigar, flag):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
99 if (cigar == "*"):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
100 cigarOps = []
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
101 elif (flag & 0x0010):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
102 cigarOpStrings = cigarSearch.findall(cigar)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
103 cigarOps = []
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
104 for opString in cigarOpStrings:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
105 cigarOpList = atomicCigarSearch.findall(opString)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
106 # print cigarOpList
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
107 # "struct" for the op and it's length
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
108 cigar = cigarOp(cigarOpList[0][0], cigarOpList[0][1])
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
109 # add to the list of cigarOps
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
110 cigarOps.append(cigar)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
111 cigarOps = cigarOps
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
112 cigarOps.reverse()
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
113 # do in reverse order because negative strand
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
114 else:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
115 cigarOpStrings = cigarSearch.findall(cigar)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
116 cigarOps = []
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
117 for opString in cigarOpStrings:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
118 cigarOpList = atomicCigarSearch.findall(opString)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
119 # "struct" for the op and it's length
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
120 cigar = cigarOp(cigarOpList[0][0], cigarOpList[0][1])
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
121 # add to the list of cigarOps
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
122 cigarOps.append(cigar)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
123 # cigarOps = cigarOps
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
124 return(cigarOps)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
125
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
126
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
127 def calcQueryPosFromCigar(cigarOps):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
128 qsPos = 0
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
129 qePos = 0
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
130 qLen = 0
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
131 # if first op is a H, need to shift start position
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
132 # the opPosition counter sees if the for loop is looking
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
133 # at the first index of the cigar object
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
134 opPosition = 0
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
135 for cigar in cigarOps:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
136 if opPosition == 0 and (cigar.op == 'H' or cigar.op == 'S'):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
137 qsPos += cigar.length
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
138 qePos += cigar.length
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
139 qLen += cigar.length
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
140 elif opPosition > 0 and (cigar.op == 'H' or cigar.op == 'S'):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
141 qLen += cigar.length
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
142 elif cigar.op == 'M' or cigar.op == 'I':
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
143 qePos += cigar.length
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
144 qLen += cigar.length
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
145 opPosition += 1
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
146 d = queryPos(qsPos, qePos, qLen)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
147 return d
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
148
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
149
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
150 class cigarOp (object):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
151 """
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
152 sturct to store a discrete CIGAR operations
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
153 """
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
154 def __init__(self, opLength, op):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
155 self.length = int(opLength)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
156 self.op = op
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
157
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
158
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
159 class queryPos (object):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
160 """
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
161 struct to store the start and end positions of query CIGAR operations
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
162 """
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
163 def __init__(self, qsPos, qePos, qLen):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
164 self.qsPos = int(qsPos)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
165 self.qePos = int(qePos)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
166 self.qLen = int(qLen)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
167
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
168
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
169 def calcQueryOverlap(s1, e1, s2, e2):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
170 o = 1 + min(e1, e2) - max(s1, s2)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
171 return max(0, o)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
172
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
173 ###############################################
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
174
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
175
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
176 class Usage(Exception):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
177 def __init__(self, msg):
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
178 self.msg = msg
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
179
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
180
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
181 def main():
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
182 usage = """%prog -i <file>
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
183
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
184 extractSplitReads_BwaMem v0.1.0
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
185 Author: Ira Hall
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
186 Description: Get split-read alignments from bwa-mem in lumpy compatible
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
187 format. Ignores reads marked as duplicates.
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
188 Works on read or position sorted SAM input. Tested on bwa mem v0.7.5a-r405.
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
189 """
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
190 parser = OptionParser(usage)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
191
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
192 parser.add_option("-i", "--inFile", dest="inFile",
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
193 help="A SAM file or standard input (-i stdin).",
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
194 metavar="FILE")
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
195 parser.add_option("-n", "--numSplits", dest="numSplits", default=2,
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
196 type="int",
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
197 help='''The maximum number of split-read mappings to
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
198 allow per read. Reads with more are excluded.
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
199 Default=2''', metavar="INT")
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
200 parser.add_option("-d", "--includeDups", dest="includeDups",
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
201 action="store_true", default=0,
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
202 help='''Include alignments marked as duplicates.
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
203 Default=False''')
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
204 parser.add_option("-m", "--minNonOverlap", dest="minNonOverlap",
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
205 default=20, type="int", help='''minimum non-overlap between
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
206 split alignments on the query (default=20)''',
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
207 metavar="INT")
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
208 (opts, args) = parser.parse_args()
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
209 if opts.inFile is None:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
210 parser.print_help()
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
211 print
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
212 else:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
213 try:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
214 extractSplitsFromBwaMem(opts.inFile, opts.numSplits,
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
215 opts.includeDups, opts.minNonOverlap)
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
216 except IOError as err:
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
217 sys.stderr.write("IOError " + str(err) + "\n")
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
218 return
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
219
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
220
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
221 if __name__ == "__main__":
a1225091082c "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 6a109f553d1691e243372258ad564244586875c3"
artbio
parents:
diff changeset
222 sys.exit(main())