annotate microsatcompat.py @ 4:ecfc9041bcc5

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