This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Want to edit bioperl script for making .ptt files (for each contig) from .gbk files.

Hello. I am currently doing pangenome analysis of multiple genome strains simultaneously.I am using PGAP-X pipeline. For this purpose, I have to convert .gbk files into .ptt file.My questions are: 1) Is there any on click tool or Python code to convert the .gbk files into .ptt files? 2) From Biostars website, I have found a Bioperl script for the conversion, However since I am a newbie in script writing; I am unable to understand the errors present in the script. I have tried running it on Padre The Perl and it shows error in line 3 (BOLD) 3) I don't know where and how to take my saved .gbk file as an input to get the desired output. Do I have to take one file at a a time?

#!/usr/bin/env perl
use strict;
**use Bio::SeqIO;**
my $gbk = Bio::SeqIO->new(-fh=>\*STDIN, -format=>'genbank');
my $seq = $gbk->next_seq;
my @cds = grep { $_->primary_tag eq 'CDS' } $seq->get_SeqFeatures;

print $seq->description, " - 0..",$seq->length,"\r\n";
print scalar(@cds)," proteins\r\n";
print join("\t", qw(Location Strand Length PID Gene Synonym Code COG 
Product)),"\r\n";

for my $f (@cds) {
   my $gi = '-';
   $gi = $1 if tag($f, 'db_xref') =~ m/\bGI:(\d+)\b/;
   my $cog = '-';
   $cog = $1 if tag($f, 'product') =~ m/^(COG\S+)/;
   my @col = (
     $f->start.'..'.$f->end,
     $f->strand >= 0 ? '+' : '-',
     ($f->length/3)-1,
     $gi,
     tag($f, 'gene'),
     tag($f, 'locus_tag'),
     $cog,
     tag($f, 'product'),
   );
   print join("\t", @col), "\r\n";
}

sub tag {
   my($f, $tag) = @_;
   return '-' unless $f->has_tag($tag);
   return join(' ', $f->get_tag_values($tag));
}`
genome software error perl dna-seq python

Does Padre show any error message? In any case you should use #!/usr/bin/env perl instead of !/usr/bin/env perl. And error with use Bio::SeqIO could be because this module is not installed. You can install it by opening CPAN client from start menu and running these commands:

get Bio::SeqIO
make Bio::SeqIO
test Bio::SeqIO
install Bio::SeqIO

You may also try Unix & Perl Primer book which is suited for beginners in programming.

Please guide me how to input my .gbk file in the above script?

Let's say your file is called seqs.gbk and is in the same folder as Perl script. All you need to do is to change the line:

my $gbk = Bio::SeqIO->new(-fh=>\*STDIN, -format=>'genbank');

to this:

my $gbk = Bio::SeqIO->new(-file=>'seqs.gbk', -format=>'genbank');

By doing this you change the script in a way that it reads not from standard input (STDIN) but from file seqs.gbk.

0 answers

No answers yet.

Log in to answer this question.