[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

output format

Posted on 2004-04-08
1
Medium Priority
?
219 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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
Suggested Courses

872 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