Hi All,
I have an output data from CHARMM program which I am trying to parse. So, there are three variable in my output program "HEAD, TAIL, WAT" on which I have to count the number of occurence each time and print the values.
I have attached the output data of the program and my script file.
[code=data]
CHARMM> coor contact cut 4.5 sele HEAD end sele RES .and. .not. HEAD end
MEMB POPC 41 O3 1.0000
CHARMM> coor contact cut 4.5 sele TAIL end sele RES .and. .not. TAIL end
MEMB POPC 30 C21 2.0000
MEMB POPC 30 O22 3.0000
MEMB POPC 30 C22 1.0000
MEMB POPC 41 C3 3.0000
MEMB POPC 41 O31 2.0000
MEMB POPC 41 C31 2.0000
MEMB POPC 41 O32 3.0000
CHARMM> coor contact cut 4.5 sele WAT end sele RES .and. .not. WAT end
TIP3 TIP3 257 OH2 4.0000
TIP3 TIP3 524 OH2 3.0000
TIP3 TIP3 3687 OH2 2.0000
TIP3 TIP3 3798 OH2 7.0000
TIP3 TIP3 4038 OH2 3.0000
TIP3 TIP3 5218 OH2 3.0000
TIP3 TIP3 7177 OH2 1.0000
CHARMM> coor contact cut 4.5 sele HEAD end sele RES .and. .not. HEAD end
CHARMM> coor contact cut 4.5 sele TAIL end sele RES .and. .not. TAIL end
MEMB POPC 30 C21 1.0000
MEMB POPC 30 O22 2.0000
MEMB POPC 30 C22 2.0000
MEMB POPC 41 C3 7.0000
MEMB POPC 41 O31 5.0000
MEMB POPC 41 C31 3.0000
MEMB POPC 41 O32 3.0000
MEMB POPC 41 C32 1.0000
CHARMM> coor contact cut 4.5 sele WAT end sele RES .and. .not. WAT end
TIP3 TIP3 524 OH2 1.0000
TIP3 TIP3 2474 OH2 1.0000
TIP3 TIP3 3687 OH2 1.0000
TIP3 TIP3 3798 OH2 7.0000
TIP3 TIP3 4038 OH2 4.0000
TIP3 TIP3 5196 OH2 1.0000
TIP3 TIP3 5218 OH2 2.0000
TIP3 TIP3 7177 OH2 2.0000
CHARMM> coor contact cut 4.5 sele HEAD end sele RES .and. .not. HEAD end
MEMB POPC 41 O3 2.0000
CHARMM> coor contact cut 4.5 sele TAIL end sele RES .and. .not. TAIL end
MEMB POPC 30 C21 1.0000
MEMB POPC 30 O22 3.0000
MEMB POPC 30 C22 2.0000
MEMB POPC 41 C3 5.0000
MEMB POPC 41 O31 1.0000
MEMB POPC 41 C31 2.0000
MEMB POPC 41 O32 2.0000
[/code]
here is my perl code
[code=perl]
#!/usr/bin/perl
use strict;
use warnings;
my $i = 0;
my ($cnt1, $cnt2, $cnt3) = 0;
my $temp = "temp.dat";
open (A,"<$temp");
while(my $line = <A>)
{
if($line=~/ MEMB\s+POPC\s+\ S+\s+\S+\s+(\S+ )/)
{
if($1 > 0)
{
$cnt1++;
}
}
elsif($line=~/ MEMB\s+POPC\s+\ S+\s+\S+\s+(\S+ )/)
{
if($1 > 0)
{
$cnt2++;
}
}
elsif($line=~/ TIP3\s+TIP3\s+\ S+\s+\S+\s+(\S+ )/)
{
if($1 > 0)
{
$cnt3++;
}
}
elsif($line=~/coor contact cut 4.5 sele HEAD/)
{
printf "%4d %5d %5d\n",$i,$cnt1 ,$cnt2,$cnt3;
$cnt1=0;$cnt2=0 ;$cnt3=0;
$i++;
}
else
{
next;
}
}
printf "%4d %5d %5d\n",$i,$cnt1 ,$cnt2;$cnt3;
[/code]
As you can see from the data and code, I am trying to parse the content of each group (HEAD, TAIL, WAT) and writing the data, the problem I am facing is not able to count for the HEAD and the TAIL portion of the data as the regular expression i am using is not correct. Any help on this will be appreciated.
Thanks
I have an output data from CHARMM program which I am trying to parse. So, there are three variable in my output program "HEAD, TAIL, WAT" on which I have to count the number of occurence each time and print the values.
I have attached the output data of the program and my script file.
[code=data]
CHARMM> coor contact cut 4.5 sele HEAD end sele RES .and. .not. HEAD end
MEMB POPC 41 O3 1.0000
CHARMM> coor contact cut 4.5 sele TAIL end sele RES .and. .not. TAIL end
MEMB POPC 30 C21 2.0000
MEMB POPC 30 O22 3.0000
MEMB POPC 30 C22 1.0000
MEMB POPC 41 C3 3.0000
MEMB POPC 41 O31 2.0000
MEMB POPC 41 C31 2.0000
MEMB POPC 41 O32 3.0000
CHARMM> coor contact cut 4.5 sele WAT end sele RES .and. .not. WAT end
TIP3 TIP3 257 OH2 4.0000
TIP3 TIP3 524 OH2 3.0000
TIP3 TIP3 3687 OH2 2.0000
TIP3 TIP3 3798 OH2 7.0000
TIP3 TIP3 4038 OH2 3.0000
TIP3 TIP3 5218 OH2 3.0000
TIP3 TIP3 7177 OH2 1.0000
CHARMM> coor contact cut 4.5 sele HEAD end sele RES .and. .not. HEAD end
CHARMM> coor contact cut 4.5 sele TAIL end sele RES .and. .not. TAIL end
MEMB POPC 30 C21 1.0000
MEMB POPC 30 O22 2.0000
MEMB POPC 30 C22 2.0000
MEMB POPC 41 C3 7.0000
MEMB POPC 41 O31 5.0000
MEMB POPC 41 C31 3.0000
MEMB POPC 41 O32 3.0000
MEMB POPC 41 C32 1.0000
CHARMM> coor contact cut 4.5 sele WAT end sele RES .and. .not. WAT end
TIP3 TIP3 524 OH2 1.0000
TIP3 TIP3 2474 OH2 1.0000
TIP3 TIP3 3687 OH2 1.0000
TIP3 TIP3 3798 OH2 7.0000
TIP3 TIP3 4038 OH2 4.0000
TIP3 TIP3 5196 OH2 1.0000
TIP3 TIP3 5218 OH2 2.0000
TIP3 TIP3 7177 OH2 2.0000
CHARMM> coor contact cut 4.5 sele HEAD end sele RES .and. .not. HEAD end
MEMB POPC 41 O3 2.0000
CHARMM> coor contact cut 4.5 sele TAIL end sele RES .and. .not. TAIL end
MEMB POPC 30 C21 1.0000
MEMB POPC 30 O22 3.0000
MEMB POPC 30 C22 2.0000
MEMB POPC 41 C3 5.0000
MEMB POPC 41 O31 1.0000
MEMB POPC 41 C31 2.0000
MEMB POPC 41 O32 2.0000
[/code]
here is my perl code
[code=perl]
#!/usr/bin/perl
use strict;
use warnings;
my $i = 0;
my ($cnt1, $cnt2, $cnt3) = 0;
my $temp = "temp.dat";
open (A,"<$temp");
while(my $line = <A>)
{
if($line=~/ MEMB\s+POPC\s+\ S+\s+\S+\s+(\S+ )/)
{
if($1 > 0)
{
$cnt1++;
}
}
elsif($line=~/ MEMB\s+POPC\s+\ S+\s+\S+\s+(\S+ )/)
{
if($1 > 0)
{
$cnt2++;
}
}
elsif($line=~/ TIP3\s+TIP3\s+\ S+\s+\S+\s+(\S+ )/)
{
if($1 > 0)
{
$cnt3++;
}
}
elsif($line=~/coor contact cut 4.5 sele HEAD/)
{
printf "%4d %5d %5d\n",$i,$cnt1 ,$cnt2,$cnt3;
$cnt1=0;$cnt2=0 ;$cnt3=0;
$i++;
}
else
{
next;
}
}
printf "%4d %5d %5d\n",$i,$cnt1 ,$cnt2;$cnt3;
[/code]
As you can see from the data and code, I am trying to parse the content of each group (HEAD, TAIL, WAT) and writing the data, the problem I am facing is not able to count for the HEAD and the TAIL portion of the data as the regular expression i am using is not correct. Any help on this will be appreciated.
Thanks
Comment