Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I have a file of blast results of different sequences. Some of them have "no hits found", and the others have hits. How do I obtain the lines which have the results , ignoring the initial lines.

Here"s what a file looks like

BLASTX 2.2.26 [Sep-21-2011] Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaff +er, Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), "Gapped BLAST and PSI-BLAST: a new generation of protein database sear +ch programs", Nucleic Acids Res. 25:3389-3402. Query= XLOC_000039-chr1:983051-985037 (1987 letters) Database: nr 26,236,801 sequences; 9,088,244,489 total letters Searching..................................................done Score + E Sequences producing significant alignments: (bits +) Value ref|XP_002322127.1| autoinhibited H+ ATPase [Populus trichocarpa... +195 2e-93 emb|CAD29314.1| plasma membrane H+-ATPase [Oryza sativa Japonica... +213 1e-55 ref|NP_001048647.1| Os03g0100800 [Oryza sativa Japonica Group] >... +213 1e-55 gb|EEC74325.1| hypothetical protein OsI_09609 [Oryza sativa Indi... +213 1e-55 gb|EMT10609.1| ATPase 11, plasma membrane-type [Aegilops tauschii] +208 3e-54 ref|XP_002511598.1| H(\+)-transporting atpase plant/fungi plasma... +207 3e-54 ref|XP_002274074.1| PREDICTED: ATPase 7, plasma membrane-type is... +207 5e-54 ref|XP_003633895.1| PREDICTED: ATPase 7, plasma membrane-type is... +207 6e-54 gb|AAA34099.1| plasma membrane H+ ATPase, partial [Nicotiana plu... +197 8e-54 ref|XP_003562242.1| PREDICTED: plasma membrane ATPase 1-like [Br... +207 8e-54 ref|XP_002326870.1| autoinhibited H+ ATPase [Populus trichocarpa... +206 1e-53 ref|XP_003529038.1| PREDICTED: plasma membrane ATPase 1-like iso... +205 4e-53

There are many hits, but if I want the top ten only, what do i do?

here"s the code i got so far for my entire task, I managed to do the first part, but am stuck at this one

#!usr/bin/perl -w open(IN,"/home/maize/sequence-ID.txt"); open(OUT,">abc.txt"); open(OUT1,">blastresults.txt"); while($id=<IN>) { $id=~s/\n|\r//g; open(BLAST,"output/$id"); while($file=<BLAST>) { if ($file=~ m/No hits found/) { print OUT "$id \n"; } } close(BLAST); } close(IN); close(OUT); close(OUT1);

so now i've created a text file which has the names of all those files without any hits. Now i have to create another file with the names of those which have significatn hits, along with the first ten hits. Please help :(


I figured one way of doing it,

#!usr/bin/perl -w open(IN,"/home/adithie/datasets/maize/sequence-ID.txt"); open(OUT,">lncRNA3.txt"); open(OUT1,">blastresults2.txt"); while($id=<IN>) { $id=~s/\n|\r//g; open(BLAST,"output/$id"); for($i=0;$i<16;$i++){<BLAST>;} $raw=<BLAST>; if ($raw=~ m/No hits found/) { print OUT "$id\n"; } else { <BLAST>; <BLAST>; <BLAST>; <BLAST>; $raw=<BLAST>; print OUT1 "$id\n"; $count=0; while(length($raw)>10 && $count<=10) { $count++; print OUT1 "$raw"; $raw=<BLAST>; } } close(BLAST); } close(IN); close(OUT); close(OUT1);

In reply to how do i obtain blast result from the given file by bingalee

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-05-16 19:30 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (63 votes). Check out past polls.