The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl- matrix problem aj05 Shell Programming and Scripting 2 02-20-2009 04:17 AM
problem with perl ali560045 Shell Programming and Scripting 6 05-29-2008 07:26 AM
Perl problem meevagh Shell Programming and Scripting 6 05-09-2008 04:59 PM
Having a problem with a FTP Script using perl scottzx7rr Shell Programming and Scripting 6 12-19-2007 06:26 PM
PERL function problem avadhani Shell Programming and Scripting 2 06-15-2005 04:18 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-06-2009
fordie fordie is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 2
Problem with perl ~ tr///

I am trying to run the following script which is a file format converter. The frame variable in the input file has a file of 3,2,1 which needs to be 0,1,2 respectively i.e. 3 =0 etc.
I have included the tr/// function into the script to do this, however it does not seem to be working
input its
orf00002 111 974 +3 2.94
and output should be
orf00002 Glimmer3 CDS 111 974 2 + 0 note "Glimmer3 prediction" ; colour 3

However, the output is actually

orf00002 Glimmer3 CDS 111 974 2 + 18446744073709551614 note "Glimmer3 prediction" ; colour 3

I would appreciate any help as i just can't see the problem. The script does exactly what it is supposed to do without the tr/// function but with the wrong values for the frame variable

thanks in advance and the script is included below

Brian
Code:
#!/usr/bin/perl -w

while (<>) {
    /(\S+)\s+(\d+)\s+(\d+)\s+([\/+\-])(\d)\s+(\d+)/;    
    $header = $1;
    $start = $2;
    $stop = $3;
    $strand = $4;
    $frame = $5;
    $frame = ~ tr/321/012/; 
    $score = $6;
    if ($strand eq "+"){
        print "$header\tGlimmer3\tCDS\t$start\t$stop\t$score\t$strand\t$frame\tnote \"Glimmer3 prediction\" ; colour 3\n";
    }elsif ($strand eq "-"){
        print "$header\tGlimmer3\tCDS\t$stop\t$start\t$score\t$strand\t$frame\tnote \"Glimmer3 prediction\" ; colour 3\n";
    }
}

Last edited by pludi; 10-06-2009 at 05:26 AM.. Reason: code tags please....
  #2 (permalink)  
Old 10-06-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,839
Your problem is this line:
Code:
$frame = ~ tr/321/012/;
It will take the number of transformations done by tr (0), invert it bitwise, and assign it to $frame. What you want is:
Code:
$frame =~ tr/321/012/;
Remember, when hunting bugs, these four lines can save you a lot of time:
Code:
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
  #3 (permalink)  
Old 10-06-2009
fordie fordie is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 2
thanks
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0