annotate extractSplitReads_BwaMem.py @ 6:48e97429a749 draft default tip

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