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

Uploaded
author matteoc
date Thu, 22 Dec 2016 04:45:31 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/de_prokka/de_prokka.pl	Thu Dec 22 04:45:31 2016 -0500
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+use strict;
+my $fas_file=shift;
+my $ann_file=shift;
+my $out_file=shift;
+
+open(OUT,">$out_file");
+
+my %seqS=();
+my $id="";
+open(IN,$fas_file);
+while(<IN>)
+{
+	if ($_=~/^>(.*)/)
+	{
+		$id=$1;
+		$id=(split(/\s+/,$id))[0];
+	}else{
+		$seqS{$id}.=$_;
+	}
+}
+
+my %decode=();
+open(IN,$ann_file);
+while(<IN>)
+{
+	last if $_=~/^\#\#FASTA/;
+	next if $_=~/^\#/;
+	my ($id1,$id2)=(split(/\t/))[0,-1];
+	$id2=(split(/\;/,$id2))[0];
+	my @vl=(split(/\_/,$id1));
+	$id1="";
+	foreach my $v (@vl)
+	{
+		if ($v eq "length")
+		{
+			chop($id1);
+			last;
+		}
+		$id1.="$v\_"; 
+	}
+	$id2=~s/ID=//;
+	$decode{$id2}=$id1;
+}
+foreach my $seq (sort keys %seqS)
+{
+	print OUT ">$decode{$seq}\z\z\z$seq\n$seqS{$seq}\n";
+}
+