【发布时间】:2017-12-09 00:13:54
【问题描述】:
我正在尝试从 pdb 文件中取出某些列。我已经在我的代码中删除了所有以 ATOM 开头的行。出于某种原因,我的子功能不起作用,我不知道在哪里或如何调用它们。 我的代码是:
open (FILE, $ARGV[0])
or die "Could not open file\n";
my @newlines;
while ( my $line = <FILE> ) {
if ($line =~ m/^ATOM.*/) {
push @newlines, $line;
}
}
my $atomcount = @newlines;
#print "@newlines\n";
#print "$atomcount\n";
##############################################################
#This function will take out the element from each line
#The element is from column 77 and contains one or two letters
sub atomfreq {
foreach my $record1(@newlines) {
my $element = substr($record1, 76, 2);
print "$element\n";
return;
}
}
################################################################
#This function will take out the residue name from each line
#The element is from column 18 and contains 3 letters
sub resfreq {
foreach my $record2(@newlines) {
my $residue = substr($record2, 17, 3);
print "$residue\n";
return;
}
}
【问题讨论】: