Mercurial > repos > genouest > feelnc2asko
annotate feelnc2asko.pl @ 2:d30ecf96e4cd draft default tip
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit c0c2ee6f693fd83d002ed5b19ac52639790d2b6f
author | genouest |
---|---|
date | Fri, 20 Apr 2018 03:07:40 -0400 |
parents | af75f883cab4 |
children |
rev | line source |
---|---|
0
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
1 use strict; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
2 use warnings; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
3 use Getopt::Long; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
4 use Bio::Tools::GFF; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
5 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
6 my ($anngff, $lncgff, $newgff); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
7 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
8 GetOptions("ann=s" => \$anngff, "lnc=s" => \$lncgff, "new=s" => \$newgff); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
9 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
10 my $gffout = Bio::Tools::GFF->new(-fh=> \*STDOUT, -gff_version => 3); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
11 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
12 #1. the standard annotation |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
13 my $gffin = Bio::Tools::GFF->new(-file => $anngff, -gff_version => 3); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
14 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
15 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
16 while (my $feature = $gffin->next_feature()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
17 if ($feature-> primary_tag eq 'mRNA') { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
18 my ($gene)=$feature->get_tag_values("gene"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
19 $feature->remove_tag("Parent"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
20 $feature->add_tag_value("Parent", $gene); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
21 $feature->add_tag_value("feelnc_type", "standard"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
22 $gffout->write_feature($feature); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
23 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
24 if ($feature-> primary_tag eq 'gene') { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
25 my ($name)=$feature->get_tag_values("Name"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
26 $feature->remove_tag("ID"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
27 $feature->add_tag_value("ID", $name); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
28 $feature->add_tag_value("feelnc_type", "standard"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
29 $gffout->write_feature($feature); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
30 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
31 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
32 $gffin->close(); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
33 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
34 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
35 my %genes=(); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
36 my %transcripts=(); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
37 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
38 #2. The lncRNA gtf |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
39 my $fncgtf = Bio::Tools::GFF->new( -file => $lncgff, -gff_version => '2' ); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
40 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
41 while (my $feat = $fncgtf->next_feature()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
42 next if ($feat->primary_tag() ne 'exon'); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
43 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
44 my $mrna= ($feat->get_tag_values('transcript_id'))[0]; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
45 my $gene= ($feat->get_tag_values('gene_id'))[0]; |
2
d30ecf96e4cd
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit c0c2ee6f693fd83d002ed5b19ac52639790d2b6f
genouest
parents:
1
diff
changeset
|
46 if ($gene eq $mrna) {$mrna.=".mrna"} |
0
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
47 # print STDERR "str: ", $feat->strand(), "\n"; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
48 if (exists($genes{$gene})) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
49 if ($genes{$gene}->start() > $feat->start()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
50 $genes{$gene}->start($feat->start()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
51 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
52 if ($genes{$gene}->end() < $feat->end()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
53 $genes{$gene}->end($feat->end()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
54 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
55 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
56 else { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
57 my $geneft = Bio::SeqFeature::Generic->new( |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
58 -start => $feat->start(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
59 -end => $feat->end(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
60 -strand => $feat->strand(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
61 -primary_tag => 'gene', |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
62 -source_tag => $feat->source_tag(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
63 -seq_id => $feat->seq_id()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
64 # $geneft->add_tag_value("feelnc_type", "lncRNA"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
65 $genes{$gene}=$geneft; |
1
af75f883cab4
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 35a0acc7d7337781f376517f0ef821d836fc4bb9
genouest
parents:
0
diff
changeset
|
66 $geneft->add_tag_value("ID", $gene); |
0
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
67 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
68 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
69 if (exists($transcripts{$mrna})) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
70 if ($transcripts{$mrna}->start() > $feat->start()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
71 $transcripts{$mrna}->start($feat->start()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
72 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
73 if ($transcripts{$mrna}->end() < $feat->end()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
74 $transcripts{$mrna}->end($feat->end()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
75 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
76 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
77 else { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
78 my $tr = Bio::SeqFeature::Generic->new( |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
79 -start => $feat->start(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
80 -end => $feat->end(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
81 -strand => $feat->strand(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
82 -primary_tag => 'mRNA', |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
83 -source_tag => $feat->source_tag(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
84 -seq_id => $feat->seq_id()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
85 $tr->add_tag_value("ID", $mrna); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
86 $tr->add_tag_value("Parent",$gene); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
87 $tr->add_tag_value("feelnc_type", "lncRNA"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
88 $transcripts{$mrna}=$tr; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
89 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
90 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
91 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
92 #3. The new mRNA gtf |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
93 my $nmgtf = Bio::Tools::GFF->new( -file => $newgff, -gff_version => '2' ); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
94 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
95 while (my $feat = $nmgtf->next_feature()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
96 next if ($feat->primary_tag() ne 'exon'); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
97 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
98 my $mrna= ($feat->get_tag_values('transcript_id'))[0]; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
99 my $gene= ($feat->get_tag_values('gene_id'))[0]; |
2
d30ecf96e4cd
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit c0c2ee6f693fd83d002ed5b19ac52639790d2b6f
genouest
parents:
1
diff
changeset
|
100 if ($gene eq $mrna) {$mrna.=".mrna"} |
0
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
101 # print STDERR "str: ", $feat->strand() , "\n"; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
102 if (exists($genes{$gene})) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
103 if ($genes{$gene}->start() > $feat->start()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
104 $genes{$gene}->start($feat->start()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
105 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
106 if ($genes{$gene}->end() < $feat->end()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
107 $genes{$gene}->end($feat->end()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
108 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
109 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
110 else { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
111 my $geneft = Bio::SeqFeature::Generic->new( |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
112 -start => $feat->start(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
113 -end => $feat->end(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
114 -strand => $feat->strand(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
115 -primary_tag => 'gene', |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
116 -source_tag => $feat->source_tag(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
117 -seq_id => $feat->seq_id()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
118 $geneft->add_tag_value("ID", $gene); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
119 # $geneft->add_tag_value("feelnc_type", "new"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
120 $genes{$gene}=$geneft; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
121 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
122 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
123 if (exists($transcripts{$mrna})) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
124 if ($transcripts{$mrna}->start() > $feat->start()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
125 $transcripts{$mrna}->start($feat->start()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
126 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
127 if ($transcripts{$mrna}->end() < $feat->end()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
128 $transcripts{$mrna}->end($feat->end()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
129 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
130 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
131 else { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
132 my $tr = Bio::SeqFeature::Generic->new( |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
133 -start => $feat->start(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
134 -end => $feat->end(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
135 -strand => $feat->strand(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
136 -primary_tag => 'mRNA', |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
137 -source_tag => $feat->source_tag(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
138 -seq_id => $feat->seq_id()); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
139 $tr->add_tag_value("ID", $mrna); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
140 $tr->add_tag_value("Parent",$gene); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
141 $tr->add_tag_value("feelnc_type", "new"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
142 $transcripts{$mrna}=$tr; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
143 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
144 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
145 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
146 foreach my $mrna (keys %transcripts) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
147 my ($parent)=$transcripts{$mrna}->get_tag_values("Parent"); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
148 $gffout->write_feature($genes{$parent}); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
149 $gffout->write_feature($transcripts{$mrna}); |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
150 } |