This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract multi-line protein sequences with Ids present in headers ?

Hi all Can anyone tell me how to retrieve multi-line protein sequences with Ids present in headers?

>gi|1706522686|gb|QDM68077.1| CraA [Acinetobacter baumannii]
MKNIQTTALNRTTLMFPLALVLFEFAVYIGNDLIQPAMLAITEDFGVSATWAPSSMSFYLLGGASVAWLL
GPLSDRLGRKKVLLSGVLFFALCCFLILLTRQIEHFLTLRFLQGIGLSVISAVGYAAIQENFAERDAIKV
MALM
>gi|1818457412|dbj|BCA98153.1| 1-acyl-sn-glycerol-3-phosphate acyltransferase [Acinetobacter baumannii]
MTQTQSIVNSTLKKFSKIGLYGKKVTSATAAISEGFYLVYRHGLYKDPNNPVNTRYVQYFCRRLCQVFNL
EVQVHGTIPREPALWVSNHISWLDIAVLGSGARVFFLAKAEIEKWPILGNLAKGGGTLFIKRGSGDSIKI

>gi|1818457412|dbj|BCA98158.1| 1-acyl-phosphate acyltransferase [Acinetobacter baumannii]
MTQTQSIVNSTLKKFSKIGLYGKKVTSATAAISEGFYLVYRHGLYKDPNNPVNTRYVQYFCRRLCQVFNL
EVQVHGTIPREPALWVSNHISWLDIAVLGSGARVFFLAKAEIEKWPILGNLAKGGGTLFIKRGSGDSIKI

and I have Ids like

QDM68077.1
BCA98153.1

Please let me know how to retrieve sequnces for these Ids. Would appreciate if someone tell me how to use seqkit. I have used seqkit like

seqkit grep -nrif remaining_except_core 307_DR_determinats.fasta but getting nothing from this command.

perl awk sed

1 answer

Easy with seqmagick:

# if you have full IDs
seqmagick convert --include-from-file ids.txt input.fa output.fa

# if you have partial IDs, you can match patterns
seqmagick convert --pattern-include REGEX input.fa output.fa

Log in to answer this question.