-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsampler.py
executable file
·46 lines (38 loc) · 1010 Bytes
/
sampler.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
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import argparse
import glob
import math
import random
import os
import statistics
import sys
from grimoire.genome import Reader
import isoform
#######
# CLI #
#######
parser = argparse.ArgumentParser(description='model builder for apc set')
parser.add_argument('apc', help='path to apc directory')
arg = parser.parse_args()
for ff in glob.glob(f'{arg.apc}/*.fa'):
print(ff)
icount = {}
gf = ff[:-2] + 'gff3'
genome = Reader(gff=gf, fasta=ff)
chrom = next(genome)
introns = []
scores = []
for f in chrom.ftable.features:
if f.source == 'RNASeq_splice':
introns.append( (f.beg, f.end) )
scores.append(f.score)
for exp in range(5):
seen = set()
for i in range(10, 1000, 10):
for intron in random.choices(introns, weights=scores, k=i):
seen.add(intron)
n = len(seen) # number of introns seen so far
if i not in icount: icount[i] = []
icount[i].append(n)
for samples, data in icount.items():
print(samples, statistics.mean(data), flush=True)