How to display only the chains (such as A, C, E, G) which end with a semicolon ;
Data
COMPND MOL_ID: 1;
COMPND 2 MOLECULE: JACALIN;
COMPND 3 CHAIN: A, C, E, G;
COMPND 4 SYNONYM: JACKFRUIT
AGGLUTININ;
COMPND 5 MOL_ID: 2;
COMPND 6 MOLECULE: JACALIN;
COMPND 7 CHAIN: B, D, F, H;
COMPND 8 SYNONYM: JACKFRUIT AGGLUTININ
I tried the below code
#!usr/local/bin/perl
open(FILE, "/home/httpd/cgi-bin/r/1JAC.pdb");
while ( $line = <FILE> ) {
if ( $line =~ /^COMPND/ ) {
#$line = substr $line,4,21;
my $line =~ m(/\$:^\w+\$\;/g);
print $line;
}
}
You can use a single regular expression like the following:
This uses a regular expression to match COMPND, CHAIN and an ending
;. The\s*at the end of the regular expression will match any trailing spaces. It will capture the string betweenCHAIN:and;excluding trailing and leading spaces in$1which is set as the value for the$chainvariable.More information on Perldoc: Perlre - Perl regular expressions.