File: parse_read.py

package info (click to toggle)
hinge 0.5.0-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,972 kB
  • sloc: cpp: 9,480; ansic: 8,826; python: 5,023; sh: 340; makefile: 10
file content (28 lines) | stat: -rwxr-xr-x 658 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/python3

import sys

def parse_read(stream = sys.stdin):    
    sid = ''
    seq = ''
    with stream as f:
        for l in f:
            if l[0] == '>':
                if sid == '':
                    sid = l[1:].strip()
                else:
                    tsid = sid
                    tseq = seq
                    seq = ''
                    sid = l[1:].strip()
                    yield (tsid,tseq)
                    
            else:
                seq += l.strip()
            
        yield(sid,seq)
                
                
#for read in parse_read():
#    print read
# do whatever you want to do with the reads