annotate de_prokka/de_prokka.pl @ 0:68a3648c7d91 draft default tip

Uploaded
author matteoc
date Thu, 22 Dec 2016 04:45:31 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
1 #!/usr/bin/perl -w
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
2 use strict;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
3 my $fas_file=shift;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
4 my $ann_file=shift;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
5 my $out_file=shift;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
6
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
7 open(OUT,">$out_file");
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
8
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
9 my %seqS=();
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
10 my $id="";
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
11 open(IN,$fas_file);
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
12 while(<IN>)
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
13 {
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
14 if ($_=~/^>(.*)/)
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
15 {
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
16 $id=$1;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
17 $id=(split(/\s+/,$id))[0];
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
18 }else{
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
19 $seqS{$id}.=$_;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
20 }
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
21 }
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
22
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
23 my %decode=();
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
24 open(IN,$ann_file);
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
25 while(<IN>)
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
26 {
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
27 last if $_=~/^\#\#FASTA/;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
28 next if $_=~/^\#/;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
29 my ($id1,$id2)=(split(/\t/))[0,-1];
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
30 $id2=(split(/\;/,$id2))[0];
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
31 my @vl=(split(/\_/,$id1));
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
32 $id1="";
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
33 foreach my $v (@vl)
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
34 {
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
35 if ($v eq "length")
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
36 {
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
37 chop($id1);
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
38 last;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
39 }
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
40 $id1.="$v\_";
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
41 }
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
42 $id2=~s/ID=//;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
43 $decode{$id2}=$id1;
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
44 }
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
45 foreach my $seq (sort keys %seqS)
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
46 {
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
47 print OUT ">$decode{$seq}\z\z\z$seq\n$seqS{$seq}\n";
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
48 }
68a3648c7d91 Uploaded
matteoc
parents:
diff changeset
49