Solved

output format

Posted on 2004-04-08
1
210 Views
Last Modified: 2010-03-04
Hi All,

Iwadwell has been doing sterling work with me on this program...but I just have to change the output format if you guys can help?

My current output is like this:
Line1:1  ,3  ,...19 ,20 ,...101,105
Line2:E  ,S  ,...W ,P   ,....P   ,Q  
Line3:3  ,5
Line4:W ,F

what I need is this:
Surface residues chainA:1  ,3  ,...19 ,20 ,...101,105
Residue name chainA:E  ,S  ,...W ,P   ,....P   ,Q  
Surface residues chainB:3  ,5
Residue name chainB:W ,F

I may have to change the "chainA" and "chainB" parts when I'm running it so if this could be scripted in the program so I can change it..well, that would be great.  The program is below...I hope ye can help!



#!/usr/bin/perl
use strict;

my %vals = (A => 113,
            V => 160,
            L => 180,
            I => 182,
            P => 143,
            W => 259,
            F => 218,
            M => 204,
            G => 85,
            S => 122,
            T => 146,
            Y => 229,
            C => 140,
            N => 158,
            Q => 189,
            K => 211,
            R => 241,
            H => 194,
            D => 151,
            E => 183,
            X => "N");

my $offset    = 0;
my $linecnt   = 1;

my @ResVals   = ();
my @AAVals    = ();

open(INFILE, "/home/sarah/test") or die "cannot open input file $!";
open(OUTFILE, '>HP') or die "cannot open output file $!";
while (my $line = <INFILE>) {
     next if ($line =~ /HYDROGEN/);

     my $residual = substr($line, 0,5);
     $residual =~ s/ //g;
     my $AA       = substr($line,21,1);
     $AA =~ s/ //g;
     my $ACC      = substr($line,63,5);
     $ACC =~ s/ //g;
     my $Reset    = substr($line,12,2);
     
     if ($Reset =~ /\*/) {
           printf OUTFILE "Line%d:%s\n" , $linecnt, join(",", map{sprintf("%-3s", $_)} @ResVals);
           $linecnt++;
           printf OUTFILE "Line%d:%s\n" , $linecnt, join(",", map{sprintf("%-3s", $_)} @AAVals);
           $linecnt++;
          @ResVals   = ();
          @AAVals    = ();
         
          $offset = $residual;
     }
     my $relres = $residual - $offset;
     
     my $calcval = -1;
     if (defined($vals{$AA})) {
          $calcval = ($ACC / $vals{$AA}) * 100;
     }
     
     if ($calcval > 50) {  ## store the values only if the calculated value is greater than 50
          push @ResVals, $relres;
          push @AAVals, $AA;
     }
}
if ($#ResVals >= 0) {
     printf OUTFILE "Line%d:%s\n" , $linecnt, join(",", map {sprintf("%-3s", $_)} @ResVals);
     $linecnt++;
     printf OUTFILE "Line%d:%s\n" , $linecnt, join(",", map {sprintf("%-3s", $_)} @AAVals);
     $linecnt++;    
}

close(INFILE);
close(OUTFILE);
 
0
Comment
Question by:sarahJo
1 Comment
 
LVL 4

Accepted Solution

by:
vi_srikanth earned 500 total points
ID: 10789468
I think u want to change the "Line1..." to "" . Am I right? In that case, just change the OUTPUT lines to

      printf OUTFILE "Surface residues chainA:%s\n" ,  join(",", map{sprintf("%-3s", $_)} @ResVals);

I have replaced the "Line%d" by "Surface residues chainA" and have removed the $linecnt.  Similarly u have to do for the remaining three.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now