Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Extract multiple lists od Identifiers from a FASTA file

by Anonymous Monk
on Aug 04, 2022 at 13:56 UTC ( [id://11145950]=note: print w/replies, xml ) Need Help??


in reply to Extract multiple lists od Identifiers from a FASTA file

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Extract multiple lists od Identifiers from a FASTA file
by AnomalousMonk (Archbishop) on Aug 04, 2022 at 15:44 UTC
    open OUT,'>'."$path/$name.faa" || die ("cannot open out $file $!\n");

    Unless joluito has been busy making uncited changes behind the scenes (update: /msg from pryrt says changes were made), the quoted statement is not present in the OPed code. However, I agree with your point about evaluation order in this statement.

    ... the real problem [is] setting the global variable $/

    $/ = "\>";

    and then never restoring it back to "\n".

    Although trollishly delivered, I agree that failure to restore $/ is a problem, likely the root problem. No one else has made this point (update: yet — but see this).


    Give a man a fish:  <%-{-{-{-<

      Pretty sure was stealth edited because that was the reason I called it out as incorrect and needing parens as written at the time.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

Re^2: Extract multiple lists od Identifiers from a FASTA file (trojan trolling)
by LanX (Saint) on Aug 04, 2022 at 16:28 UTC
    > Anyway, Guido was right and Larry failed.

    And Guido retired because he couldn't stand anymore the hate in that "community".

    FWIW: I voted "edit", because you were clever enough to envelop valid points with trolling, I'd call this trojan trolling.

    IMHO we should just reap the original (for the archive) and repost the valid points.

    (Keep the horse, burn the Greeks)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Re^2: Extract multiple lists od Identifiers from a FASTA file
by joluito (Novice) on Aug 04, 2022 at 14:40 UTC

    Didn't expect to find such trolls in a place like this...

    But anyway, he nailed it about changing the filed separator.

    Here's is the FUNCTIONAL code (may indentation not be that good, and the code not obfuscated enough as to win a contest...but we need it to be mantained by different people, some of who are new to programming).

    #!usr/bin/perl -w use strict; use Getopt::Long; #usage example: perl /path_to_script/bay_seqret.pl -p /path_to_lists - +f /path_to_fasta/FASTA_file.faa my ($path, $fasta); GetOptions( 'path=s' => \$path, 'fasta=s' => \$fasta, ); chdir $path or die "ERROR: Unable to enter $path: $!\n"; opendir (TEMP , "."); my @files = readdir (TEMP); closedir TEMP; my $name; my $found=0; my $totalist=0; $/ = "\>";###CHANGED HERE TO SPLIT FASTA by ">" open (INFILE, "$path/$fasta") || die ("cannot open input file"); chomp(my @data = <INFILE>); print"@data\n"; $/ = "\n";####"REGENERATED" HERE NOT TO INTERFERE WITH THE REST OF THE + DATA PROCESSING for my $file (@files) { if($file=~/(\w+)\.txt/){ $name = "$1"; print"Lista: $path/$name.txt\n"; open (INFILE2, "$path/$name.txt") || die ("cannot open input f +ile"); chomp(my @lista = <INFILE2>); open OUT,'>'."$path/$name.out" or die "ERROR: Unable to open +$file $!\n"; foreach my $li (@lista){ chomp $li; print"$li\n"; $totalist++; for(@data){ if(/$li/){ $found++; print ">"."$_\n"; print OUT ">"."$_\n"; } } } print "For $name we found $found of a total $totalist\n"; } }

      It will be gone in a minute or two because it’s not tolerated here.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (1)
As of 2024-04-24 14:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found