Mercurial > repos > arkarachai-fungtammasan > fakename
comparison microsatcompat.py @ 0:70f8259b0b30 draft
Uploaded
author | arkarachai-fungtammasan |
---|---|
date | Wed, 01 Apr 2015 16:48:58 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:70f8259b0b30 |
---|---|
1 import sys | |
2 # remove all read that have unmatch microsat | |
3 # check only one line at a time | |
4 def complement_base(read): | |
5 collect='' | |
6 for i in read: | |
7 if i.upper()=='A': | |
8 collect+='T' | |
9 elif i.upper()=='T': | |
10 collect+='A' | |
11 elif i.upper()=='C': | |
12 collect+='G' | |
13 elif i.upper()=='G': | |
14 collect+='C' | |
15 return collect | |
16 | |
17 def makeallpossible(read): | |
18 collect=[] | |
19 for i in range(len(read)): | |
20 tmp= read[i:]+read[:i] | |
21 collect.append(tmp) | |
22 collect.append(complement_base(tmp)) | |
23 return collect | |
24 | |
25 | |
26 fd=open(sys.argv[1]) | |
27 lines=fd.xreadlines() | |
28 firstcolumn=int(sys.argv[2])-1 #4 | |
29 secondcolumn=int(sys.argv[3])-1 # 10 | |
30 for line in lines: | |
31 temp=line.strip().split('\t') | |
32 temp=filter(None,temp) | |
33 micro1=temp[firstcolumn] | |
34 micro2=temp[secondcolumn] | |
35 if micro1 in makeallpossible(micro2): | |
36 print line.strip() |