Mercurial > repos > genouest > feelnc2asko
annotate feelnc2asko.pl @ 0:e323c49b8bcc draft
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
author | genouest |
---|---|
date | Thu, 12 Apr 2018 06:05:23 -0400 |
parents | |
children | af75f883cab4 |
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]; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
46 # 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
|
47 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
|
48 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
|
49 $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 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
51 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
|
52 $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 } |
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 else { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
56 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
|
57 -start => $feat->start(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
58 -end => $feat->end(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
59 -strand => $feat->strand(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
60 -primary_tag => 'gene', |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
61 -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
|
62 -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
|
63 # $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
|
64 $genes{$gene}=$geneft; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
65 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
66 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
67 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
|
68 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
|
69 $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
|
70 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
71 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
|
72 $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
|
73 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
74 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
75 else { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
76 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
|
77 -start => $feat->start(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
78 -end => $feat->end(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
79 -strand => $feat->strand(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
80 -primary_tag => 'mRNA', |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
81 -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
|
82 -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
|
83 $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
|
84 $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
|
85 $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
|
86 $transcripts{$mrna}=$tr; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
87 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
88 } |
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 #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
|
91 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
|
92 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
93 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
|
94 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
|
95 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
96 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
|
97 my $gene= ($feat->get_tag_values('gene_id'))[0]; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
98 # 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
|
99 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
|
100 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
|
101 $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
|
102 } |
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}->end() < $feat->end()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
104 $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
|
105 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
106 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
107 else { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
108 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
|
109 -start => $feat->start(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
110 -end => $feat->end(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
111 -strand => $feat->strand(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
112 -primary_tag => 'gene', |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
113 -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
|
114 -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
|
115 $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
|
116 # $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
|
117 $genes{$gene}=$geneft; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
118 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
119 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
120 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
|
121 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
|
122 $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
|
123 } |
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}->end() < $feat->end()) { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
125 $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
|
126 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
127 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
128 else { |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
129 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
|
130 -start => $feat->start(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
131 -end => $feat->end(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
132 -strand => $feat->strand(), |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
133 -primary_tag => 'mRNA', |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
134 -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
|
135 -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
|
136 $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
|
137 $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
|
138 $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
|
139 $transcripts{$mrna}=$tr; |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
140 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
141 } |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
142 |
e323c49b8bcc
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/feelnc2asko commit 92849224db1963d090fbb25d410cc659a5449241
genouest
parents:
diff
changeset
|
143 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
|
144 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
|
145 $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
|
146 $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
|
147 } |