Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Renaming headers works for some files but fails for some files

by Random_Walk (Prior)
on May 09, 2013 at 10:21 UTC ( [id://1032754]=note: print w/replies, xml ) Need Help??


in reply to Renaming headers works for some files but fails for some files

You only print lines to your output file when they contain no whitespace.

if( /^(\S+)$/) {print OFILE"$1\n\n"}

From your input that may not be what you want. Are you after the first contiguous sequence on each line AFTER the first text with the scaffold<num> or just the entire line with the first part altered?

It would also be good practice to explicitly close your files when you are finished reading/writing them.

Update

# this may help while (my $line = <FILE>) { # The entire line with a substitution # if( $line =~ s/^>\S+\/>contig_$count) { # Substitution and 1st contiguous sequence if( $line =~ s/^>\S+\s+(\S+)/>contig_$count $1\n/) { print OFILE $line; $count++; } } close FILE; close OFILE;

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1032754]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found