annotate extractSplitReads_BwaMem.py @ 1:1ed8619a5611 draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
author artbio
date Wed, 26 Jul 2017 18:17:01 -0400
parents 796552c157de
children 48e97429a749
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:
1
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
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 # print cigarOpList
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
107 # "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
108 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
109 # 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
110 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
111 cigarOps = cigarOps
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
112 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
113 # 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
114 else:
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
115 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
116 cigarOps = []
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
117 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
118 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
119 # "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
120 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
121 # 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
122 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
123 # cigarOps = cigarOps
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
124 return(cigarOps)
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
125
1
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
diff changeset
126
0
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
127 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
128 qsPos = 0
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
129 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
130 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
131 # 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
132 # 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
133 # 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
134 opPosition = 0
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
135 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
136 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
137 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
138 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
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 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
141 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
142 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
143 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
144 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
145 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
146 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
147 return d
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
148
1
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
diff changeset
149
0
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
150 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
151 """
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
152 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
153 """
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
154 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
155 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
156 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
157
0
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 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
160 """
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
161 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
162 """
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
163 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
164 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
165 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
166 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
167
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
168
1
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
diff changeset
169 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
170 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
171 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
172
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
173 ###############################################
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
174
1
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
diff changeset
175
0
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
176 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
177 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
178 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
179
1
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
diff changeset
180
0
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
181 def main():
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
182 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
183
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
184 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
185 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
186 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
187 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
188 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
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 = OptionParser(usage)
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
191
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204 parser.add_option("-m", "--minNonOverlap", dest="minNonOverlap",
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
diff changeset
205 default=20, type="int", help='''minimum non-overlap between
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
diff changeset
206 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
207 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
208 (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
209 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
210 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
211 print
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
212 else:
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
213 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
214 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
215 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
216 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
217 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
218 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
219
1ed8619a5611 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents: 0
diff changeset
220
0
796552c157de planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff changeset
221 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
222 sys.exit(main())