annotate microsatcompat.py @ 1:99ec84eb0bab draft default tip

Uploaded
author arkarachai-fungtammasan
date Wed, 01 Apr 2015 17:00:21 -0400
parents 70f8259b0b30
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
1 import sys
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
2 # remove all read that have unmatch microsat
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
3 # check only one line at a time
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
4 def complement_base(read):
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
5 collect=''
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
6 for i in read:
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
7 if i.upper()=='A':
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
8 collect+='T'
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
9 elif i.upper()=='T':
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
10 collect+='A'
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
11 elif i.upper()=='C':
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
12 collect+='G'
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
13 elif i.upper()=='G':
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
14 collect+='C'
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
15 return collect
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
16
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
17 def makeallpossible(read):
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
18 collect=[]
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
19 for i in range(len(read)):
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
20 tmp= read[i:]+read[:i]
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
21 collect.append(tmp)
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
22 collect.append(complement_base(tmp))
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
23 return collect
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
24
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
25
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
26 fd=open(sys.argv[1])
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
27 lines=fd.xreadlines()
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
28 firstcolumn=int(sys.argv[2])-1 #4
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
29 secondcolumn=int(sys.argv[3])-1 # 10
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
30 for line in lines:
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
31 temp=line.strip().split('\t')
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
32 temp=filter(None,temp)
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
33 micro1=temp[firstcolumn]
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
34 micro2=temp[secondcolumn]
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
35 if micro1 in makeallpossible(micro2):
70f8259b0b30 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
36 print line.strip()