1

I have a text file from which 0 hits found protein is needed. I am using Linux suse. Any command using awk or sed will be appreciated

# BLASTP 2.2.31+
# Query: ABO10498.2 DNA replication initiator protein [Acinetobacter baumannii ATCC 17978]
# Database: uniprot-reviewed%3Ayes+AND+proteome%3Aup000005640.fasta
# Fields: query id, subject id, evalue, % identity, % query coverage per subject
# 1 hits found
# BLASTP 2.2.31+
# Query: ABO10538.2 hypothetical protein A1S_0043 [Acinetobacter baumannii ATCC 17978]
# Database: uniprot-reviewed%3Ayes+AND+proteome%3Aup000005640.fasta
# 0 hits found
# Query: ABO10591.2 putative acetyl-coA synthetase/AMP-(fatty) acid ligase [Acinetobacter baumannii ATCC 17978]
# Database: uniprot-reviewed%3Ayes+AND+proteome%3Aup000005640.fasta
# Fields: query id, subject id, evalue, % identity, % query coverage per subject
# 23 hits found
# BLASTP 2.2.31+
# Query: ABO10598.2 eR transcriptional regulator [Acinetobacter baumannii ATCC 17978]
# Database: uniprot-reviewed%3Ayes+AND+proteome%3Aup000005640.fasta
# 0 hits found

desired output:

# BLASTP 2.2.31+
# Query: ABO10538.2 hypothetical protein A1S_0043 [Acinetobacter baumannii ATCC 17978]
# Database: uniprot-reviewed%3Ayes+AND+proteome%3Aup000005640.fasta
# 0 hits found
# BLASTP 2.2.31+
# Query: ABO10598.2 eR transcriptional regulator [Acinetobacter baumannii ATCC 17978]
# Database: uniprot-reviewed%3Ayes+AND+proteome%3Aup000005640.fasta
# 0 hits found
0
7

If the pattern stays the same, you can use

grep -B 3 '# 0 hits found'

This will print all lines containing # 0 hits found and the three lines before the match.

The different hits are sperated by a line contining --. So you might want to add | grep -v '^--' to the command.

1
  • Yup, that would be the quickest solution :)
    – Ziazis
    May 17 '17 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.