forked from sreeramkannan/Shannon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc_s.py
40 lines (29 loc) · 1011 Bytes
/
rc_s.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys,pdb,time, math, multiprocessing, copy
D={'A':'T','C':'G','G':'C','T':'A','N':'N'}
reverse_complement = lambda x: ''.join([D[B] for B in x][::-1])
nJobs = 20
def reverse_complement_serial(infile,outfile):
reads = []
if 1: #with open(outfile,'w') as of:
for line in open(infile):
if not line.strip(): continue
fields = line.strip().split()
if fields[0][0]=='>':
reads.append(line.strip())
else:
reads.append(reverse_complement(fields[0]))
with open(outfile,'w') as of:
of.write('\n'.join(reads) + '\n')
def main():
if len(sys.argv) == 1:
arguments = ['asd', 'in_fasta', 'out_fasta', '-d']
else:
arguments = sys.argv[1:]
#pdb.set_trace()
infile, outfile = arguments[:2]
#pdb.set_trace()
reverse_complement_serial(infile, outfile)
if __name__ == '__main__':
#c1 = Counter("Loading", 10**6)
#c2 = Counter("Correction", 10**6)
main()