comparison phyloconversion/prune_phytab_using_list.py @ 0:5b9a38ec4a39 draft default tip

First commit of old repositories
author osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
date Tue, 11 Mar 2014 12:19:13 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:5b9a38ec4a39
1 #!/usr/bin/python -tt
2
3 ##usage: ./pullgoodseqs.py <originalphytab> <bls2remove> <keep|discard> > outfile
4 #import modules
5 import sys, os, numpy, re
6
7 def read(filename):
8 f = open(filename)
9 bad = open(sys.argv[2])
10 lines = f.readlines()
11 badlines = bad.readlines()
12 badstripped = [line[:-1] for line in badlines]
13 str1 = '|'.join(badstripped)
14 str2 = '('+str1[:-1]+')'
15 pattern = re.compile(str2)
16 count=0
17 for line in lines:
18 # line.strip()
19 match = pattern.findall(line)
20 if match and sys.argv[3] == 'keep':
21 print line,
22 if not match and sys.argv[3] == 'discard':
23 print line,
24 bad.close()
25 f.close()
26
27 def main():
28 read(sys.argv[1])
29
30 if __name__ == '__main__':
31 main()