annotate Iterative_mapping/seq_track.py @ 119:7bb98e9296e9 draft default tip

Uploaded
author tyty
date Tue, 14 Apr 2015 14:18:40 -0400
parents d56631911cc1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d56631911cc1 Uploaded
tyty
parents:
diff changeset
1 #!/usr/bin/env python
d56631911cc1 Uploaded
tyty
parents:
diff changeset
2 # -*- coding: utf-8 -*-
d56631911cc1 Uploaded
tyty
parents:
diff changeset
3
d56631911cc1 Uploaded
tyty
parents:
diff changeset
4 import sys
d56631911cc1 Uploaded
tyty
parents:
diff changeset
5 from read_file import *
d56631911cc1 Uploaded
tyty
parents:
diff changeset
6 from Bio import SeqIO
d56631911cc1 Uploaded
tyty
parents:
diff changeset
7
d56631911cc1 Uploaded
tyty
parents:
diff changeset
8 unmap_file = sys.argv[1]
d56631911cc1 Uploaded
tyty
parents:
diff changeset
9 reads_file = sys.argv[2]
d56631911cc1 Uploaded
tyty
parents:
diff changeset
10 result_file = sys.argv[3]
d56631911cc1 Uploaded
tyty
parents:
diff changeset
11 tp = sys.argv[4]
d56631911cc1 Uploaded
tyty
parents:
diff changeset
12
d56631911cc1 Uploaded
tyty
parents:
diff changeset
13
d56631911cc1 Uploaded
tyty
parents:
diff changeset
14 unmap = read_t_file(unmap_file);
d56631911cc1 Uploaded
tyty
parents:
diff changeset
15
d56631911cc1 Uploaded
tyty
parents:
diff changeset
16 h = file(result_file, 'w')
d56631911cc1 Uploaded
tyty
parents:
diff changeset
17
d56631911cc1 Uploaded
tyty
parents:
diff changeset
18 reads = SeqIO.parse(reads_file,tp)
d56631911cc1 Uploaded
tyty
parents:
diff changeset
19 um = set()
d56631911cc1 Uploaded
tyty
parents:
diff changeset
20 for i in range(0, len(unmap)):
d56631911cc1 Uploaded
tyty
parents:
diff changeset
21 id_r = unmap[i][0]
d56631911cc1 Uploaded
tyty
parents:
diff changeset
22 um.add(id_r)
d56631911cc1 Uploaded
tyty
parents:
diff changeset
23
d56631911cc1 Uploaded
tyty
parents:
diff changeset
24 for read in reads:
d56631911cc1 Uploaded
tyty
parents:
diff changeset
25 if read.id in um:
d56631911cc1 Uploaded
tyty
parents:
diff changeset
26 h.write('>')
d56631911cc1 Uploaded
tyty
parents:
diff changeset
27 h.write(read.id)
d56631911cc1 Uploaded
tyty
parents:
diff changeset
28 h.write('\n')
d56631911cc1 Uploaded
tyty
parents:
diff changeset
29 h.write(read.seq.tostring())
d56631911cc1 Uploaded
tyty
parents:
diff changeset
30 h.write('\n')
d56631911cc1 Uploaded
tyty
parents:
diff changeset
31
d56631911cc1 Uploaded
tyty
parents:
diff changeset
32
d56631911cc1 Uploaded
tyty
parents:
diff changeset
33
d56631911cc1 Uploaded
tyty
parents:
diff changeset
34 h.close()
d56631911cc1 Uploaded
tyty
parents:
diff changeset
35
d56631911cc1 Uploaded
tyty
parents:
diff changeset
36
d56631911cc1 Uploaded
tyty
parents:
diff changeset
37
d56631911cc1 Uploaded
tyty
parents:
diff changeset
38