This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extraction of best alignment in blast out put

Hey everyone

I have about 4000 blast tab limited output, from thees output I want to extract best alignment (first line only) and want to store another different 4000 files. How is it possible using awk or some other programme

Please help me

perl awk sequence blast

Hi,

Can you post the first 10 lines or so from your tab limited output?

GCF_000196095n.fasta_2    GCF_001270975n.fasta_3470    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_001270945n.fasta_718    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_001270905n.fasta_1870    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_001270885n.fasta_614    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_001270825n.fasta_533    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_001270815n.fasta_2554    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_001006105n.fasta_866    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_000975195n.fasta_1323    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_000972045n.fasta_4282    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_000960685n.fasta_1698    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_000958595n.fasta_2383    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_000951795n.fasta_4194    100.00    1362    0    0    1    1362    1    1362    0.0    2516

output am expecting like this

GCF_000196095n.fasta_2    GCF_001270975n.fasta_3470    100.00    1362    0    0    1    1362    1    1362    0.0    2516

Caution: there is no 'best' alignment in your example, all alignments you show have equal score, identity, e-value etc. The first one is by no means the best. I don't know what you want to do with the output, but using only the first line is often not a good strategy.

Showing some sample data in your hand and how you are expecting the output file would help to figure it out and more importantly 'posting what you have tried so far is a good practice'.

input file

GCF_000196095n.fasta_2    GCF_001270975n.fasta_3470    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_001270945n.fasta_718    100.00    1362    0    0    1    1362    1    1362    0.0    2516
GCF_000196095n.fasta_2    GCF_001270905n.fasta_1870    100.00    1362    0    0    1    1362    1    1362    0.0    2516

then expected out put

GCF_000196095n.fasta_2    GCF_001270975n.fasta_3470    100.00    1362    0    0    1    1362    1    1362    0.0    2516

Do you need each of the line in different file? (Please edit your question instead of using comment box)

2 answers

you could have simply used head -1

i got a awk comment like this

 awk 'NR==1' inputfile > outputfile

this ll work for my problem

So, you want only the first line, and then discard the remaining lines? Or, do you want each of your 4000 lines in 4000 different files?

Edit: Never mind. If you got a solution, that's good enough!

On a related note, please use professional language. I'd phrase your response so:


Yes, I would like each line in a different file. I used the following awk command to solve my problem: awk 'NR==1' inputfile > outputfile

This works for my case. Thank you for your support.


SMS/IM jargon, typos, improper casing, etc make you look like you're not serious about what you're doing. As another bioinformatician from Chennai, I know the emphasis our folks have on being good at professional communication. Here's to hoping you'll work on this aspect!

Thank you for your suggestions. I will take everything you have said into consideration.

Log in to answer this question.