File: parse_alignment.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 (26 lines) | stat: -rwxr-xr-x 760 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
#!/usr/bin/python3

import sys
import re


def parse_alignment(stream = sys.stdin):    
    with stream as f:
        for l in f:
            sub = re.sub('[\[\].x:<difstraep()]',' ',l.strip())    
            sub = re.sub(',','',sub)
            lst = sub.split()[:-1]
            if len(lst) == 9:
                yield [lst[2]] + list(map(int, lst[0:2] + lst[3:]))
                
                
def parse_alignment2(stream = sys.stdin):    
    with stream as f:
        for l in f:
            
            sub = re.sub('[\[\].x:<difstraep()/]',' ',l.strip())    
            sub = re.sub(',','',sub)
            lst = sub.split()[:-1]
            if len(lst) == 11:
                yield [lst[2]] + list(map(int, lst[0:2] + lst[3:]))