This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Modifying NCBI identifiers in BLAST output

Hi

Post blastx, I have the alignment results as a .m8 blast tabular file, with lines that look as follows

HISEQ:329:HMKF3BCXX:1:1101:4293:5950/1 gi|753197404|ref|WP_041503856.1| 54.3    81  37  0   6   248 141 221 4.4e-18 99.0

I would like to simplify the NCBI identifiers of the second column i.e. keep only the accession numbers in the blast output file, essentially something like

HISEQ:329:HMKF3BCXX:1:1101:4293:5950/1 WP_041503856.1 54.3  81  37  0   6   248 141 221 4.4e-18 99.0

Thanks

blast alignment sequencing

1 answer

awk -F '\t' '{OFS="\t";split($2,a,/\|/);$2=a[4];print;}' input.tsv > output.tsv

Thanks Pierre! Much appreciated

On another note, I am trying to simplify the fasta header which contains similar text i.e. gi|753197404|ref|WP_041503856.1|

I am currently removing the gi numbers using

sed 's/^[^ ][|]([^|])[|] .*$/>\1/'

Is there a faster alternative using awk?

Log in to answer this question.