#!/usr/bin/perl # The first line might be #!/usr/local/bin/perl etc # depending on the system. # gbk2ptable.pl: # Do not delete this comment.##################### if ( $#ARGV != 2) { print "usage: $0 infile gbkDBname newDBname.\n"; print " infile is a gbk file.\n"; print " gbk file is converted to a FASTA file and a p.table file.\n"; exit 1; } $| = 1; $infile = $ARGV[0]; $gbkDBname = $ARGV[1]; $newDBname = $ARGV[2]; @infile_list = split(/\./ , $infile); $cdsfile = $infile_list[0] . ".cds"; $command = "extcds " . $infile . " " . $cdsfile; system $command; #$fafile = $infile_list[0] . ".fa"; $fafile = $newDBname . ".fa"; open(INFILE, $cdsfile) || die "Unable to open file: $cdsfile.\n"; open(OUT, "> $fafile") || die "Unable to open file: $ptable.\n"; $counter = 1; while(){ # This part should be edited for each use. if ( $_ =~ /^\>/ ){ $_ =~ s/^\>$gbkDBname/\>$newDBname/; # unless ( $_ =~ /^\>Pm3_Pro/ ) { # @items = split(/\s+/, $_); # @name = split(/_/, $items[0]); # $newname = "g" . $counter; # $_ =~ s/$name[1]/$newname/; # chop($_); # $_ = $_ . $name[1] . "\n"; # } $counter++; } print OUT $_; } close(INFILE); close(OUT); $tempfile = $infile_list[0] . ".temp"; $command = "genlist " . $fafile . " " . $tempfile; system $command; #$ptable = $infile_list[0] . ".p.table"; $ptable = $newDBname . ".p.table"; open(INFILE, $tempfile) || die "Unable to open file: $tempfile.\n"; open(OUT, "> $ptable") || die "Unable to open file: $ptable.\n"; $line = ; $line = ; $line = ; while(){ if( $_ eq ".\n") { next; } $_ =~ s/^ID=//; $_ =~ s/\,\ /\t/; $_ =~ s/\ residues\,\s+/\t/; $_ =~ s/\d+\ complement/1/; $_ =~ s/\d+\ \d+\s+\d+\ //; $_ =~ s/\;.*\;//; print OUT $_; } close(OUT); close(INFILE); $command = "rm -f " . $cdsfile; system $command; $command = "rm -f " . $tempfile; system $command; # end