annotate test-data/microsatcompat.py @ 4:ecfc9041bcc5

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