Solved

output format

Posted on 2004-04-08
1
212 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stftime format 4 55
ppm conversion to curl on a module install 8 82
Perl File::Find alternative 1 68
html form to write data to csv 24 113
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

813 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

15 Experts available now in Live!

Get 1:1 Help Now