Solved

output format

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 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

16 Experts available now in Live!

Get 1:1 Help Now