[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

output format

Posted on 2004-04-08
1
Medium Priority
?
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
vi_srikanth earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Six Sigma Control Plans

649 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