output problems

Hi Guys,

I really thought this problem was fixed but its not working the way I want it to.

Basically, I have an input file that looks like this:

1plfBD
Interfacing Residues Chain B:21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,31 ,57 ,64 ,65
,66 ,67
Interface Residue matched cB:E  ,D  ,L  ,Q  ,C  ,V  ,C  ,L  ,K  ,T  ,I  ,R  ,K
,I  ,C
Interfacing Residues Chain D:21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,65 ,66
,67
Interface Residue matched cD:E  ,D  ,L  ,Q  ,C  ,V  ,C  ,L  ,K  ,T  ,T  ,K  ,I
,C
Neighboring Residues Chain B:30 ,32 ,56 ,58 ,63 ,68
Neighboring Residue match cB:T  ,S  ,L  ,A  ,G  ,L
Neighboring Residues Chain D:32 ,57 ,64 ,68
Neighboring Residue match cD:S  ,I  ,R  ,L

1plfBD
Surface Residues chainA:21 ,22 ,24 ,28 ,29 ,30 ,32 ,33 ,35 ,37 ,38 ,40 ,41 ,43 ,
44 ,46 ,47 ,48 ,49 ,52 ,53 ,54 ,61 ,62 ,63 ,64 ,65 ,69 ,70 ,71 ,72 ,73 ,76 ,77 ,
79 ,80 ,81 ,82 ,83 ,84 ,85
Surface Resitype chainA:E  ,D  ,Q  ,L  ,K  ,T  ,S  ,G  ,N  ,R  ,H  ,S  ,S  ,E  ,
V  ,G  ,A  ,G  ,L  ,P  ,S  ,P  ,K  ,T  ,G  ,R  ,K  ,D  ,Q  ,Q  ,N  ,P  ,K  ,K  ,
I  ,K  ,R  ,L  ,L  ,K  ,S
Surface Residues chainB:21 ,24 ,28 ,29 ,30 ,32 ,33 ,35 ,37 ,38 ,40 ,41 ,43 ,44 ,46 ,47 ,48 ,49 ,
50 ,52 ,53 ,54 ,61 ,62 ,63 ,64 ,65 ,69 ,70 ,71 ,72 ,73 ,76 ,77 ,
79 ,80 ,81 ,82 ,83 ,84 ,85
Surface Resitype chainB:E  ,Q  ,L  ,K  ,T  ,S  ,G  ,N  ,R  ,H  ,S  ,S  ,E  ,V  ,
G  ,A  ,G  ,L  ,H  ,P  ,S  ,P  ,K  ,T  ,G  ,R  ,K  ,D  ,Q  ,Q  ,N  ,P  ,K  ,K  ,
I  ,K  ,R  ,L  ,L  ,K  ,S

I have to parse this file above and if any of the numbers from the "Interfacting Residues chainA" line or "neighboring ResidueschainA" line occur in the"Surface Residues chainA"- I have to remove the number from "Surface Residues chainA" and also its corresponding Surface Resitype chainA letter(which lies directly beneath it) without altering the format I have!  This has also got to be repeated for the numbers in "Interfacting Residues chainB" or  "neighboring ResidueschainB" again, removing any of the same numbers in "Surface Residues chainB" and its corresponding "Surface Resitype chainB". It is removing the numbers ok, but not the corresponding Letters in the "Surface Resitype chainA" and "Surface Resitype chainB" lines. Can someone help?  My program is below.

My program looks like this:

open (IN,'1bbbAB60') || die "Unable to open the Input File";
undef($/); $_=<IN>; close IN;
@ChainB=();  @ChainD=();
if (m#Interfacing Residues Chain B: ?([\s,\d]*)#) {push(@ChainB,split(/\s*,\s*/,$1))};
if (m#Neighboring Residues Chain B: ?([\s,\d]*)#) {push(@ChainB,split(/\s*,\s*/,$1))};
if (m#Interfacing Residues Chain D: ?([\s,\d]*)#) {push(@ChainD,split(/\s*,\s*/,$1))};
if (m#Neighboring Residues Chain D: ?([\s,\d]*)#) {push(@ChainD,split(/\s*,s*/,$1))};
@SurfaceResidueB=();  @SurfaceResidueD=();
if (m#Surface Residues chainB: ?([\s\d,]*)#) {push(@SurfaceResidueB,split(/\s*,\s*/,$1)
)};
if (m#Surface Residues chainD: ?([\s,\d]*)#) {push(@SurfaceResidueD,split(/\s*,\s*/,$1)
)};

@ChainA{@ChainB}=(1)x@ChainB;
$SRA=join(",", map{sprintf("%-3s", $_)} grep {!$ChainB{$_}} @SurfaceResidueB);
s#(Surface Residues chainB:)[\d\s,]*#$1 $SRA#;
@ChainD{@ChainD}=(1)x@ChainD;
$SRB=join(",", map{sprintf("%-3s", $_)} grep {!$ChainD{$_}} @SurfaceResidueD);
s#(Surface Residues chainD:)[\d\s,]*#$1 $SRB#;

open (OUT,">outty.txt") or die $!;
print OUT;


The output I'm getting now is :

1plfBD
Interfacing Residues Chain B:21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,31 ,57 ,64 ,65
,66 ,67
Interface Residue matched cB:E  ,D  ,L  ,Q  ,C  ,V  ,C  ,L  ,K  ,T  ,I  ,R  ,K
,I  ,C
Interfacing Residues Chain D:21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,65 ,66
,67
Interface Residue matched cD:E  ,D  ,L  ,Q  ,C  ,V  ,C  ,L  ,K  ,T  ,T  ,K  ,I
,C
Neighboring Residues Chain B:30 ,32 ,56 ,58 ,63 ,68
Neighboring Residue match cB:T  ,S  ,L  ,A  ,G  ,L
Neighboring Residues Chain D:32 ,57 ,64 ,68
Neighboring Residue match cD:S  ,I  ,R  ,L

1plfBD
Surface Residues chainB: 33 ,35 ,37 ,38 ,40 ,41 ,43 ,44 ,46 ,47 ,48 ,49 ,52 ,53
,54 ,61 ,62 ,69 ,70 ,71 ,72 ,73 ,76 ,77 ,79 ,80 ,81 ,82 ,83 ,84 ,85
Surface Resitype chainB:E  ,D  ,Q  ,L  ,K  ,T  ,S  ,G  ,N  ,R  ,H  ,S  ,S  ,E  ,
V  ,G  ,A  ,G  ,L  ,P  ,S  ,P  ,K  ,T  ,G  ,R  ,K  ,D  ,Q  ,Q  ,N  ,P  ,K  ,K  ,
I  ,K  ,R  ,L  ,L  ,K  ,S
Surface Residues chainD: 33 ,35 ,37 ,38 ,40 ,41 ,43 ,44 ,46 ,47 ,48 ,49 ,50 ,52
,53 ,54 ,61 ,62 ,63 ,69 ,70 ,71 ,72 ,73 ,76 ,77 ,79 ,80 ,81 ,82 ,83 ,84 ,85
Surface Resitype chainD:E  ,Q  ,L  ,K  ,T  ,S  ,G  ,N  ,R  ,H  ,S  ,S  ,E  ,V  ,
G  ,A  ,G  ,L  ,H  ,P  ,S  ,P  ,K  ,T  ,G  ,R  ,K  ,D  ,Q  ,Q  ,N  ,P  ,K  ,K  ,
I  ,K  ,R  ,L  ,L  ,K  ,S

sarahJoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
@ChainA{@ChainB}=(1)x@ChainB;
#should probably be:
@ChainB{@ChainB}=(1)x@ChainB;
0
sarahJoAuthor Commented:
Hi ozo,

Yeah, sorry that was my mistake. But I still don't think the program is removing the corresponding Surface Resitype chainB and Surface Resitype chainD letters along with the numbers
0
sarahJoAuthor Commented:
So basically, the program is removing all the same numbers from "surface residues chainB" that are in the "Interfacing Residues Chain B" or "Neighboring Residues Chain B" (and obviously the same from chain D) but I need it to remove the corresponding letter from the Surface Resitype chainB line (and the same situation for chain D).
0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

ozoCommented:
open (IN,'1bbbAB60') || die "Unable to open the Input File $!";
{local $/; $_=<IN>;} close IN;
@ChainB=();  @ChainD=();
if( m#Interfacing Residues Chain B: ?([\s,\d]*)# ){push(@ChainB,split(/\s*,\s*/,$1))};
if( m#Neighboring Residues Chain B: ?([\s,\d]*)# ){push(@ChainB,split(/\s*,\s*/,$1))};
if( m#Interfacing Residues Chain D: ?([\s,\d]*)# ){push(@ChainD,split(/\s*,\s*/,$1))};
if( m#Neighboring Residues Chain D: ?([\s,\d]*)# ){push(@ChainD,split(/\s*,s*/,$1))};

    @SurfaceResidueB=();  @SurfaceResidueD=();
if( m#Surface Residues chainB: ?([\s\d,]*)# ){push@SurfaceResidueB,split/\s*,\s*/,$1 };
if( m#Surface Residues chainD: ?([\s,\d]*)# ){push@SurfaceResidueD,split/\s*,\s*/,$1 };

if( m#Surface Resitype chainB: ?([\s,\w]*)# ){push@SurfaceResitypeB,split/\s*,\s*/,$1 };
if( m#Surface Resitype chainD: ?([\s,\w]*)# ){push@SurfaceResitypeD,split/\s*,\s*/,$1 };
    @ResitypeB{@SurfaceResidueB} = @SurfaceResitypeB;
    @ResitypeD{@SurfaceResidueD} = @SurfaceResitypeD;
    @ChainB{@ChainB}=(1)x@ChainB;
    $SRA=join(",", map{sprintf("%-3s", $_)} grep {!$ChainB{$_}} @SurfaceResidueB);
s#(Surface Residues chainB:)[\d\s,]*#$1$SRA#;
    @ChainD{@ChainD}=(1)x@ChainD;
    $SRB=join(",", map{sprintf("%-3s", $_)} grep {!$ChainD{$_}} @SurfaceResidueD);
s#(Surface Residues chainD:)[\d\s,]*#$1$SRB#;
   
    $SR = join",",map{sprintf("%-3s",$ResitypeB{$_})} grep {!$ChainB{$_}} @SurfaceResidueB;
s#(Surface Resitype chainB:)[\w\s,]*#$1$SR#;

     $SR = join",",map{sprintf("%-3s",$ResitypeD{$_})} grep {!$ChainD{$_}} @SurfaceResidueD;
s#(Surface Resitype chainD:)[\w\s,]*#$1$SR#;

    open (OUT,">outty.txt") or die $!;
    print OUT;
0
sarahJoAuthor Commented:
Hi ozo,

That program is removing the letters now, which is great but it is still not removing some of the numbers in "interfacing residue chains" and "neighboring residue chains" from the "surface Residue chains". I tried it on the below example..I'll give the input file, the program and the output. I hope you can help...you're really good at this.  As you can see, for example, in the output 178 from the "interface chainA"and 179 from the "neighboring chainA" are still been collected in the surface residuesChainA.


Input:
mdsAB
Interfacing Residues Chain A:23 ,27 ,31 ,32 ,36 ,75 ,128,129,130,150,151,168,169
,170,173,174,177,178
Interface Residue matched cA:K  ,I  ,K  ,H  ,Y  ,N  ,F  ,G  ,S  ,N  ,Q  ,W  ,E
,H  ,Y  ,L  ,Q  ,N
Interfacing Residues Chain B:23 ,27 ,31 ,32 ,36 ,75 ,128,129,130,150,151,168,169
,170,173,174,177,178
Interface Residue matched cB:K  ,I  ,K  ,H  ,Y  ,N  ,F  ,G  ,S  ,N  ,Q  ,W  ,E
,H  ,Y  ,L  ,Q  ,N
Neighboring Residues Chain A:22 ,24 ,26 ,28 ,30 ,33 ,35 ,37 ,74 ,76 ,127,131,149
,152,167,171,172,175,176,179
Neighboring Residue match cA:A  ,T  ,E  ,H  ,Q  ,H  ,A  ,V  ,R  ,N  ,R  ,G  ,P
,D  ,V  ,A  ,Y  ,K  ,Y  ,R
Neighboring Residues Chain B:22 ,24 ,26 ,28 ,30 ,33 ,35 ,37 ,74 ,76 ,127,131,149
,152,167,171,172,175,176,179
Neighboring Residue match cB:A  ,T  ,E  ,H  ,Q  ,H  ,A  ,V  ,R  ,N  ,R  ,G  ,P
,D  ,V  ,A  ,Y  ,K  ,Y  ,R

3mdsAB
Surface Residues chainA:1  ,2  ,3  ,5  ,7  ,8  ,10 ,12 ,13 ,14 ,15 ,17 ,18 ,19 ,
23 ,26 ,30 ,31 ,35 ,38 ,39 ,42 ,45 ,46 ,48 ,49 ,52 ,54 ,56 ,57 ,60 ,61 ,63 ,64 ,
67 ,68 ,70 ,71 ,72 ,74 ,88 ,91 ,92 ,93 ,96 ,97 ,99 ,100,101,103,104,107,108,109,
111,114,115,118,119,122,125,126,139,140,141,142,144,147,149,150,156,157,158,160,
175,178,179,181,182,185,189,194,198,201,202,203
Surface Resitype chainA:P  ,Y  ,P  ,K  ,P  ,D  ,G  ,P  ,Y  ,E  ,A  ,E  ,P  ,H  ,
K  ,E  ,Q  ,K  ,A  ,T  ,N  ,A  ,E  ,K  ,P  ,Y  ,G  ,E  ,E  ,V  ,R  ,H  ,A  ,A  ,
Q  ,D  ,Q  ,T  ,A  ,R  ,R  ,T  ,P  ,G  ,K  ,E  ,V  ,G  ,E  ,K  ,K  ,D  ,E  ,Q  ,
G  ,Q  ,A  ,E  ,K  ,Q  ,M  ,G  ,P  ,F  ,G  ,K  ,H  ,S  ,P  ,N  ,M  ,E  ,G  ,T  ,
K  ,N  ,R  ,A  ,D  ,Q  ,N  ,D  ,E  ,K  ,K  ,A
Surface Residues chainB:1  ,3  ,5  ,6  ,7  ,8  ,10 ,12 ,14 ,15 ,17 ,18 ,19 ,23 ,
26 ,30 ,31 ,35 ,38 ,39 ,42 ,45 ,46 ,48 ,49 ,52 ,54 ,56 ,57 ,60 ,61 ,63 ,64 ,67 ,
68 ,70 ,71 ,72 ,74 ,88 ,91 ,92 ,93 ,96 ,97 ,99 ,100,101,103,104,107,108,109,111,
114,115,117,118,119,121,122,125,126,139,140,141,142,144,147,149,157,158,160,175,
178,179,181,182,185,189,194,198,201,202,203
Surface Resitype chainB:P  ,P  ,K  ,L  ,P  ,D  ,G  ,P  ,E  ,A  ,E  ,P  ,H  ,K  ,
E  ,Q  ,K  ,A  ,T  ,N  ,A  ,E  ,K  ,P  ,Y  ,G  ,E  ,E  ,V  ,R  ,H  ,A  ,A  ,Q  ,
D  ,Q  ,T  ,A  ,R  ,R  ,T  ,P  ,G  ,K  ,E  ,V  ,G  ,E  ,K  ,K  ,D  ,E  ,Q  ,G  ,
Q  ,A  ,K  ,E  ,K  ,T  ,Q  ,M  ,G  ,P  ,F  ,G  ,K  ,H  ,S  ,P  ,E  ,G  ,T  ,K  ,
N  ,R  ,A  ,D  ,Q  ,N  ,D  ,E  ,K  ,K  ,A


program:
#!usr/local/bin/perl



open (IN,'8catAB2') || die "Unable to open the Input File $!";
{local $/; $_=<IN>;} close IN;
@ChainA=();  @ChainB=();
if( m#Interfacing Residues Chain A: ?([\s,\d]*)# ){push(@ChainA,split(/\s*,\s*/,
$1))};
if( m#Neighboring Residues Chain A: ?([\s,\d]*)# ){push(@ChainA,split(/\s*,\s*/,
$1))};
if( m#Interfacing Residues Chain B: ?([\s,\d]*)# ){push(@ChainB,split(/\s*,\s*/,
$1))};
if( m#Neighboring Residues Chain B: ?([\s,\d]*)# ){push(@ChainB,split(/\s*,s*/,$
1))};

    @SurfaceResidueA=();  @SurfaceResidueB=();
if( m#Surface Residues chainA: ?([\s\d,]*)# ){push@SurfaceResidueA,split/\s*,\s*
/,$1 };
if( m#Surface Residues chainB: ?([\s,\d]*)# ){push@SurfaceResidueB,split/\s*,\s*
/,$1 };
if( m#Surface Resitype chainA: ?([\s,\w]*)# ){push@SurfaceResitypeA,split/\s*,\s
*/,$1 };
if( m#Surface Resitype chainB: ?([\s,\w]*)# ){push@SurfaceResitypeB,split/\s*,\s
*/,$1 };
    @ResitypeA{@SurfaceResidueA} = @SurfaceResitypeA;
    @ResitypeB{@SurfaceResidueB} = @SurfaceResitypeB;
    @ChainA{@ChainA}=(1)x@ChainA;
    $SRA=join(",", map{sprintf("%-3s", $_)} grep {!$ChainA{$_}} @SurfaceResidueA
);
s#(Surface Residues chainA:)[\d\s,]*#$1$SRA#;
    @ChainB{@ChainB}=(1)x@ChainB;
    $SRB=join(",", map{sprintf("%-3s", $_)} grep {!$ChainB{$_}} @SurfaceResidueB
);
s#(Surface Residues chainB:)[\d\s,]*#$1$SRB#;
$SR = join",",map{sprintf("%-3s",$ResitypeA{$_})} grep {!$ChainA{$_}} @Surfa
ceResidueA;
s#(Surface Resitype chainA:)[\w\s,]*#$1$SR#;

     $SR = join",",map{sprintf("%-3s",$ResitypeB{$_})} grep {!$ChainB{$_}} @Surf
aceResidueB;
s#(Surface Resitype chainB:)[\w\s,]*#$1$SR#;

    open (OUT,">8catAB") or die $!;
    print OUT;

ouput

3mdsAB
Interfacing Residues Chain A:23 ,27 ,31 ,32 ,36 ,75 ,128,129,130,150,151,168,169
,170,173,174,177,178
Interface Residue matched cA:K  ,I  ,K  ,H  ,Y  ,N  ,F  ,G  ,S  ,N  ,Q  ,W  ,E
,H  ,Y  ,L  ,Q  ,N
Interfacing Residues Chain B:23 ,27 ,31 ,32 ,36 ,75 ,128,129,130,150,151,168,169
,170,173,174,177,178
Interface Residue matched cB:K  ,I  ,K  ,H  ,Y  ,N  ,F  ,G  ,S  ,N  ,Q  ,W  ,E
,H  ,Y  ,L  ,Q  ,N
Neighboring Residues Chain A:22 ,24 ,26 ,28 ,30 ,33 ,35 ,37 ,74 ,76 ,127,131,149
,152,167,171,172,175,176,179
Neighboring Residue match cA:A  ,T  ,E  ,H  ,Q  ,H  ,A  ,V  ,R  ,N  ,R  ,G  ,P
,D  ,V  ,A  ,Y  ,K  ,Y  ,R
Neighboring Residues Chain B:22 ,24 ,26 ,28 ,30 ,33 ,35 ,37 ,74 ,76 ,127,131,149
,152,167,171,172,175,176,179
Neighboring Residue match cB:A  ,T  ,E  ,H  ,Q  ,H  ,A  ,V  ,R  ,N  ,R  ,G  ,P
,D  ,V  ,A  ,Y  ,K  ,Y  ,R
3mdsAB
Surface Residues chainA:1  ,2  ,3  ,5  ,7  ,8  ,10 ,12 ,13 ,14 ,15 ,17 ,18 ,19 ,
38 ,39 ,42 ,45 ,46 ,48 ,49 ,52 ,54 ,56 ,57 ,60 ,61 ,63 ,64 ,67 ,68 ,70 ,71 ,72 ,
88 ,91 ,92 ,93 ,96 ,97 ,99 ,100,101,103,104,107,108,109,111,114,115,118,119,122,
125,126,139,140,141,142,144,147,156,157,158,160,178,179,181,182,185,189,194,198,
201,202,203
Surface Resitype chainA:P  ,Y  ,P  ,K  ,P  ,D  ,G  ,P  ,Y  ,E  ,A  ,E  ,P  ,H  ,
T  ,N  ,A  ,E  ,K  ,P  ,Y  ,G  ,E  ,E  ,V  ,R  ,H  ,A  ,A  ,Q  ,D  ,Q  ,T  ,A  ,
R  ,T  ,P  ,G  ,K  ,E  ,V  ,G  ,E  ,K  ,K  ,D  ,E  ,Q  ,G  ,Q  ,A  ,E  ,K  ,Q  ,
M  ,G  ,P  ,F  ,G  ,K  ,H  ,S  ,M  ,E  ,G  ,T  ,N  ,R  ,A  ,D  ,Q  ,N  ,D  ,E  ,
K  ,K  ,A
Surface Residues chainB:1  ,3  ,5  ,6  ,7  ,8  ,10 ,12 ,14 ,15 ,17 ,18 ,19 ,38 ,
39 ,42 ,45 ,46 ,48 ,49 ,52 ,54 ,56 ,57 ,60 ,61 ,63 ,64 ,67 ,68 ,70 ,71 ,72 ,88 ,
91 ,92 ,93 ,96 ,97 ,99 ,100,101,103,104,107,108,109,111,114,115,117,118,119,121,
122,125,126,139,140,141,142,144,147,157,158,160,178,179,181,182,185,189,194,198,
201,202,203
Surface Resitype chainB:P  ,P  ,K  ,L  ,P  ,D  ,G  ,P  ,E  ,A  ,E  ,P  ,H  ,T  ,
N  ,A  ,E  ,K  ,P  ,Y  ,G  ,E  ,E  ,V  ,R  ,H  ,A  ,A  ,Q  ,D  ,Q  ,T  ,A  ,R  ,
T  ,P  ,G  ,K  ,E  ,V  ,G  ,E  ,K  ,K  ,D  ,E  ,Q  ,G  ,Q  ,A  ,K  ,E  ,K  ,T  ,
Q  ,M  ,G  ,P  ,F  ,G  ,K  ,H  ,S  ,E  ,G  ,T  ,N  ,R  ,A  ,D  ,Q  ,N  ,D  ,E  ,
K  ,K  ,A



0
sarahJoAuthor Commented:
The input lines are all read in in one line like :
Interfacing Residues Chain A:23 ,27 ,31 ,32 ,36 ,75 ,128,129,130,150

if that helps?
0
sarahJoAuthor Commented:
Can you see anything wrong Ozo?
0
ozoCommented:
#a small typo:
if( m#Neighboring Residues Chain B: ?([\s,\d]*)# ){push(@ChainB,split(/\s*,s*/,$1))};
#should be
if( m#Neighboring Residues Chain B: ?([\s,\d]*)# ){push(@ChainB,split(/\s*,\s*/,$1))};
0
ozoCommented:
#There could also be a problem could be with the last chain on a line, which you can fix with
chomp @ChainA;
chomp @ChainB;
chomp @SurfaceResidueA;
chomp @SurfaceResidueB;
#You'll probably have to put the end of line back with
s#(Surface Residues chainA:)[\d\s,]*#$1$SRA\n#;


0
sarahJoAuthor Commented:
mmm, I'm not sure I follow...how would this look compared with my original script?  Where would I put the "chomp" part?
0
ozoCommented:
#!usr/local/bin/perl



open (IN,'8catAB2') || die "Unable to open the Input File $!";
{local $/; $_=<IN>;} close IN;
@ChainA=();  @ChainB=();
if( m#Interfacing Residues Chain A: ?([\s,\d]*)# ){push(@ChainA,split(/\s*,\s*/,
$1))};
if( m#Neighboring Residues Chain A: ?([\s,\d]*)# ){push(@ChainA,split(/\s*,\s*/,
$1))};
if( m#Interfacing Residues Chain B: ?([\s,\d]*)# ){push(@ChainB,split(/\s*,\s*/,
$1))};
if( m#Neighboring Residues Chain B: ?([\s,\d]*)# ){push(@ChainB,split(/\s*,s*/,$
1))};

    @SurfaceResidueA=();  @SurfaceResidueB=();
if( m#Surface Residues chainA: ?([\s\d,]*)# ){push@SurfaceResidueA,split/\s*,\s*
/,$1 };
if( m#Surface Residues chainB: ?([\s,\d]*)# ){push@SurfaceResidueB,split/\s*,\s*
/,$1 };
if( m#Surface Resitype chainA: ?([\s,\w]*)# ){push@SurfaceResitypeA,split/\s*,\s
*/,$1 };
if( m#Surface Resitype chainB: ?([\s,\w]*)# ){push@SurfaceResitypeB,split/\s*,\s
*/,$1 };

chomp @ChainA;
chomp @ChainB;
chomp @SurfaceResidueA;
chomp @SurfaceResidueB;
chomp @SurfaceResitypeA;
chomp @SurfaceResitypeB;

    @ResitypeA{@SurfaceResidueA} = @SurfaceResitypeA;
    @ResitypeB{@SurfaceResidueB} = @SurfaceResitypeB;
    @ChainA{@ChainA}=(1)x@ChainA;
    $SRA=join(",", map{sprintf("%-3s", $_)} grep {!$ChainA{$_}} @SurfaceResidueA
);
s#(Surface Residues chainA:)[\d\s,]*#$1$SRA\n#;
    @ChainB{@ChainB}=(1)x@ChainB;
    $SRB=join(",", map{sprintf("%-3s", $_)} grep {!$ChainB{$_}} @SurfaceResidueB
);
s#(Surface Residues chainB:)[\d\s,]*#$1$SRB\n#;
$SR = join",",map{sprintf("%-3s",$ResitypeA{$_})} grep {!$ChainA{$_}} @SurfaceResidueA;
s#(Surface Resitype chainA:)[\w\s,]*#$1$SR\n#;

     $SR = join",",map{sprintf("%-3s",$ResitypeB{$_})} grep {!$ChainB{$_}} @SurfaceResidueB;
s#(Surface Resitype chainB:)[\w\s,]*#$1$SR\n#;

    open (OUT,">8catAB") or die $!;
    print OUT;
0
sarahJoAuthor Commented:
Hi Ozo,

Thats still not removing those numbers and now my output is like this wit the surface residue chainB numbers on a different line

3mdsAB
Interfacing Residues Chain A:23 ,27 ,31 ,32 ,36 ,75 ,128,129,130,150,151,168,169
,170,173,174,177,178
Interface Residue matched cA:K  ,I  ,K  ,H  ,Y  ,N  ,F  ,G  ,S  ,N  ,Q  ,W  ,E
,H  ,Y  ,L  ,Q  ,N
Interfacing Residues Chain B:23 ,27 ,31 ,32 ,36 ,75 ,128,129,130,150,151,168,169
,170,173,174,177,178
Interface Residue matched cB:K  ,I  ,K  ,H  ,Y  ,N  ,F  ,G  ,S  ,N  ,Q  ,W  ,E
,H  ,Y  ,L  ,Q  ,N
Neighboring Residues Chain A:22 ,24 ,26 ,28 ,30 ,33 ,35 ,37 ,74 ,76 ,127,131,149
,152,167,171,172,175,176,179
Neighboring Residue match cA:A  ,T  ,E  ,H  ,Q  ,H  ,A  ,V  ,R  ,N  ,R  ,G  ,P
,D  ,V  ,A  ,Y  ,K  ,Y  ,R
Neighboring Residues Chain B:22 ,24 ,26 ,28 ,30 ,33 ,35 ,37 ,74 ,76 ,127,131,149
,152,167,171,172,175,176,179
Neighboring Residue match cB:A  ,T  ,E  ,H  ,Q  ,H  ,A  ,V  ,R  ,N  ,R  ,G  ,P
,D  ,V  ,A  ,Y  ,K  ,Y  ,R

3mdsAB
Surface Residues chainA:1  ,2  ,3  ,5  ,7  ,8  ,10 ,12 ,13 ,14 ,15 ,17 ,18 ,19 ,
23 ,26 ,30 ,31 ,35 ,38 ,39 ,42 ,45 ,46 ,48 ,49 ,52 ,54 ,56 ,57 ,60 ,61 ,63 ,64 ,
67 ,68 ,70 ,71 ,72 ,74 ,88 ,91 ,92 ,93 ,96 ,97 ,99 ,100,101,103,104,107,108,109,
111,114,115,118,119,122,125,126,139,140,141,142,144,147,149,150,156,157,158,160,
175,178,179,181,182,185,189,194,198,201,202,203
Surface Resitype chainA:P  ,Y  ,P  ,K  ,P  ,D  ,G  ,P  ,Y  ,E  ,A  ,E  ,P  ,H  ,
K  ,E  ,Q  ,K  ,A  ,T  ,N  ,A  ,E  ,K  ,P  ,Y  ,G  ,E  ,E  ,V  ,R  ,H  ,A  ,A  ,
Q  ,D  ,Q  ,T  ,A  ,R  ,R  ,T  ,P  ,G  ,K  ,E  ,V  ,G  ,E  ,K  ,K  ,D  ,E  ,Q  ,
G  ,Q  ,A  ,E  ,K  ,Q  ,M  ,G  ,P  ,F  ,G  ,K  ,H  ,S  ,P  ,N  ,M  ,E  ,G  ,T  ,
K  ,N  ,R  ,A  ,D  ,Q  ,N  ,D  ,E  ,K  ,K  ,A
Surface Residues chainB
:1  ,3  ,5  ,6  ,7  ,8  ,10 ,12 ,14 ,15 ,17 ,18 ,19 ,23 ,26 ,30 ,31 ,35 ,38 ,39
,42 ,45 ,46 ,48 ,49 ,52 ,54 ,56 ,57 ,60 ,61 ,63 ,64 ,67 ,68 ,70 ,71 ,72 ,74 ,88
,91 ,92 ,93 ,96 ,97 ,99 ,100,101,103,104,107,108,109,111,114,115,117,118,119,121
,122,125,126,139,140,141,142,144,147,149,157,158,160,175,178,179,181,182,185,189
,194,198,201,202,203
Surface Resitype chainB:P  ,P  ,K  ,L  ,P  ,D  ,G  ,P  ,E  ,A  ,E  ,P  ,H  ,K  ,
E  ,Q  ,K  ,A  ,T  ,N  ,A  ,E  ,K  ,P  ,Y  ,G  ,E  ,E  ,V  ,R  ,H  ,A  ,A  ,Q  ,
D  ,Q  ,T  ,A  ,R  ,R  ,T  ,P  ,G  ,K  ,E  ,V  ,G  ,E  ,K  ,K  ,D  ,E  ,Q  ,G  ,
Q  ,A  ,K  ,E  ,K  ,T  ,Q  ,M  ,G  ,P  ,F  ,G  ,K  ,H  ,S  ,P  ,E  ,G  ,T  ,K  ,
N  ,R  ,A  ,D  ,Q  ,N  ,D  ,E  ,K  ,K  ,A
0
ozoCommented:
What is wrong with the output you're getting now?
0
sarahJoAuthor Commented:
Im getting as above......"surface Residues ChainB" residues are moved onto a different line ie:

Surface Residues chainB
:1  ,3  ,5  ,6  ,7  ,8  ,10 ,12 ,14 ,15 ,17 ,18 ,19 ,23 ,26 ,30 ,31 ,35 ,38 ,39  (like this) plus I'm still seeing numbers eg 178 in the Surface Residues chainA and surface residues chainB
0
ozoCommented:
I'm not getting 178 in Surface Residues chain[AB]
I get
Surface Residues chainA:1  ,2  ,3  ,5  ,7  ,8  ,10 ,12 ,13 ,14 ,15 ,17 ,18 ,19 ,38 ,39 ,42 ,45 ,46 ,48 ,49 ,52 ,54 ,56 ,57 ,60 ,61 ,63 ,64 ,67 ,68 ,70 ,71 ,72 ,88 ,91 ,92 ,93 ,96 ,97 ,99 ,100,101,103,104,107,108,109,111,114,115,118,119,122,125,126,139,140,141,142,144,147,156,157,158,160,181,182,185,189,194,198,201,202,203

Surface Residues chainB:1  ,3  ,5  ,6  ,7  ,8  ,10 ,12 ,14 ,15 ,17 ,18 ,19 ,38 ,39 ,42 ,45 ,46 ,48 ,49 ,52 ,54 ,56 ,57 ,60 ,61 ,63 ,64 ,67 ,68 ,70 ,71 ,72 ,88 ,91 ,92 ,93 ,96 ,97 ,99 ,100,101,103,104,107,108,109,111,114,115,117,118,119,121,122,125,126,139,140,141,142,144,147,157,158,160,181,182,185,189,194,198,201,202,203

I think the other problem is that the S in "Surface Residues chainB" looks like more of ([\s,\w]*)
That can be fixed with

if( m#Surface Resitype chainA:\s*((\w\s+,\s*)*\w)# ){push@SurfaceResitypeA,split/\s*,\s*/,$1 };
if( m#Surface Resitype chainB:\s*((\w\s+,\s*)*\w)# ){push@SurfaceResitypeB,split/\s*,\s*/,$1 };

chomp @ChainA;
chomp @ChainB;
chomp @SurfaceResidueA;
chomp @SurfaceResidueB;
chomp @SurfaceResitypeA;
chomp @SurfaceResitypeB;

@ResitypeA{@SurfaceResidueA} = @SurfaceResitypeA;
@ResitypeB{@SurfaceResidueB} = @SurfaceResitypeB;
@ChainA{@ChainA}=(1)x@ChainA;
$SRA=join(",", map{sprintf("%-3s", $_)} grep {!$ChainA{$_}} @SurfaceResidueA);
s#(Surface Residues chainA:)[\d\s,]*#$1$SRA\n#;
@ChainB{@ChainB}=(1)x@ChainB;
$SRB=join(",", map{sprintf("%-3s", $_)} grep {!$ChainB{$_}} @SurfaceResidueB);
s#(Surface Residues chainB:)[\d\s,]*#$1$SRB\n#;
$SR = join",",map{sprintf("%-3s",$ResitypeA{$_})} grep {!$ChainA{$_}} @SurfaceResidueA;
s#(Surface Resitype chainA:\s*)(\w\s+,\s*)*\w#$1$SR\n#;

$SR = join",",map{sprintf("%-3s",$ResitypeB{$_})} grep {!$ChainB{$_}} @SurfaceResidueB;
s#(Surface Resitype chainB:\s*)(\w\s+,\s*)*\w#$1$SR\n#;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sarahJoAuthor Commented:
You're brilliant Ozo....many thanks...sleepless nights are over! Sarah
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.