I am final year bioinformatics student, doing final year project on "Protein Database". Im using lots of .pdb files, rely alot. I saved all the .pdb files in a folder. Following that i want parse all the .pdb files simultaneously around (50 - 60 .pdb files) and output in a single output file. I dont want to input file name manualy in 'cmd'. Instead,i want the perl script that can read the stored .pdb files in the folder as input, 1 by 1..
(THIS IS THE PERL SCRIPT THAT HELPED ME ALOT. BUT I WANT TO PARSE AROUND 50-60 .pdb FILES WHICH IS STORED IN A FOLDER 1 BY 1 AND OUTPUT IN A SINGLE TEXT FILE. I DONT WANT ENTER THE STORED .pdb FILE NAMES MANULAY IN COMMAND PROMPT)
(THANKS TO MR.JORGE AMIGO LECHUGA)
#!/usr/bin/perl -w
#
# coordExtract.pl
# # parser that allows editing a pdb
# file to extract the coordinates
#
# Jorge Amigo Lechuga
#
#######################
# READ THE INPUT FILE #
#######################
# input file query
print "\nEnter the input file: ";
$inputFile = <STDIN>;
chomp $inputFile;
unless (open(INPUTFILE, $inputFile)) {
print "Cannot read from '$inputFile'.\nProgram closing.\n";
<STDIN>;
exit;
}
# load the file into an array
chomp(@dataArray = <INPUTFILE>);
# close the file
close(INPUTFILE);
###############
# LET'S WORK! #
###############
# parse the input file saving only backbone atoms coordinates
# format: [string "ATOM"] [number] [atom] [aa] whateva [3 decimal numbers] whateva with two dots in between
for ($line = 0; $line < scalar @dataArray; $line++) {
if ($dataArray[$line] =~ m/ATOM\s+\d+\s+(\w+)\s+\w{3}\s+.+\s+(\S+\.\S+)\s+(\S+\.\S+)\s+(\S+\.\S+)\s+.+\..+\..+/ig) {
if ($1 eq "N" || $1 eq "CA" || $1 eq "C") {
$parsedData{$line} = $2."\t".$3."\t".$4;
}
}
}
# create the output file name
$outputFile = "coordinates_".$inputFile;
# open the output file
open (OUTFILE, ">$outputFile");
# print the data lines
foreach $line (sort {$a <=> $b} keys %parsedData) {
print OUTFILE $parsedData{$line}."\n";
}
# close the output file
close (OUTFILE);
# end message
print "The coordinates of '$inputFile' were saved into '$outputFile'.\n";
# end the program
exit;
hi, the perl script is running but, the loop is not working. the script give output for only 1 .pdb file. :(
OK I'm taking a look right now. That's encouraging that it's processing one file correctly. Probably just a minor tweak.
stil the same. loop is not working.
unless (open(INPUTFILE, $pdbFile)) { print "Cannot read from '$pdbFile'.\nProgram closing.\n"; ; #exit; (i disable the exit command and its stil the same) }