File: ilots_stats.py

package info (click to toggle)
minia 3.2.6-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,024 kB
  • sloc: cpp: 1,377; sh: 395; python: 208; makefile: 11
file content (40 lines) | stat: -rw-r--r-- 824 bytes parent folder | download | duplicates (4)
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
36
37
38
39
40
import sys

nb_ctg=0
nb_ilots=0
nb_connected=0

from collections import defaultdict
ctg_connect = defaultdict(bool)

assert(ctg_connect['dummy']==False)

def normalize(name):
    if name.endswith('\''):
        return name[:-1]
    return name

def header(name):
    assert(name[-1]==';')
    if ':' in name:
        res = name.split(':')[0]
    else:
        res = name.split(';')[0]
    return normalize(res)

with open(sys.argv[1]) as f:
    for line in f:
        if line.startswith('>'):
            line = line.strip()
            nb_ctg+=1
            connected = ':' in line 
            ctg_connect[header(line)] |= connected


for ctg in ctg_connect:
    if ctg_connect[ctg]:
        nb_connected += 1
    else:
        nb_ilots += 1

print("contigs input", nb_ctg/2, "connected", nb_connected, "ilots", nb_ilots)