Statistics
| Branch: | Revision:

root / Am1.0 / script / gene / make_glean.py @ 5f46a05f

History | View | Annotate | Download (1.5 kB)

1
gene={}
2
with open('snapdragon.scafseq.fa.Glean.filter.final.gff') as fin:
3
        for line in fin:
4
                lst=line.rstrip().split('\t')
5
                n=lst[8].split('=')[1].split(';')[0]
6
                if lst[2]=='mRNA':
7
                        gene[n]=[lst[0],int(lst[3])-1,lst[4],lst[6],[],[]]
8
                else:
9
                        gene[n][4].append(int(lst[3])-1)
10
                        gene[n][5].append(int(lst[4]))
11

    
12
fout=open('Glean','w')
13
fout2=open('Gleanstruct','w')
14
id=1
15

    
16
for n in gene:
17
        lst=gene[n]
18
        fout.write('{0}\t{1}\t{2}\t{3}\t{4}\t{5}\n'.format(lst[0],lst[1],lst[2],n,id,lst[3]))
19
        fout2.write('{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\n'.format(id,lst[0],lst[3],lst[1],lst[2],
20
                min(lst[4]),
21
                max(lst[5]),
22
                len(lst[4]),
23
                ','.join([str(i) for i in lst[4]]),
24
                ','.join([str(i) for i in lst[5]]),
25
                n))
26
        id+=1
27
fout.close();
28
fout2.close();
29

    
30
import os
31
os.system('sort -k1,1 -k2,2n Glean > xx')
32
os.system('mv xx Glean')
33
os.system('bgzip Glean')
34
os.system('tabix -p bed Glean.gz')
35

    
36
print '''
37
drop table if exists Gleanstruct;
38
create table Gleanstruct (
39
id int unsigned not null primary key,
40
chrom varchar(255) not null,
41
strand char(1) not null,
42
txStart int unsigned not null,
43
txEnd int unsigned not null,
44
cdsStart int unsigned not null,
45
cdsEnd int unsigned not null,
46
exonCount int unsigned not null,
47
exonStarts text not null,
48
exonEnds text not null,
49
name varchar(255) not null
50
);
51
load data local infile 'Glean.struct' into table Gleanstruct;
52

    
53
drop table if exists Gleansymbol;
54
create table Gleansymbol (
55
name varchar(255) not null,
56
symbol varchar(255) null,
57
description text null,
58
id int unsigned not null primary key,
59
index(name)
60
);
61

    
62
'''