This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Filtering FASTA sequences

Hi All,

I have the following FASTA file.....

 >NC_001434.1 Hepatitis E virus, complete genome
GCCATGGAGGCCCATCAGTTTATTAAGGCTCCTGGCATCACTACTGCTATTGAGCAGGCTGCTCTAGCAGCGGCCAACTCTGCCCTTGCGA............

 >AB189071.1 Hepatitis E virus genomic RNA, nearly complete genome, isolate: JDEER-Hyo03L
GTCGATGCCATGGAGGCCCACCAGTTTATTAAGGCTCCTGGCATTACTACTGCCATTGAGCAGGCTGCTCTGGCTGCGGCCAACTCCGCCTT...................

 >AB220979.1 Hepatitis E virus genomic RNA, complete genome, genotype 4, isolate: HE-JA41
GCAGACCACGTATGTGGTCGACGCCATGGAGGCCCACCAGTTCATAAAGGCTCCTGGCGTCACTACTGCTATTGAGCAGGCAGCTCTAGCAGC......................

 >AB220974.1 Hepatitis E virus genomic RNA, complete genome, genotype 4, isolate: HE-JA2
GCAGACCACGTATGTGGTCGACGCCATGGAGGCCCATCAGTTCATAAAGGCTCCTGGCGTCACTACTGCTATTGAGCAGGCAGCTCTAGCAGCGG...................

 >JQ001749.1 Bat hepevirus isolate BatHEV/BS7/GE/2009, complete genome
GCATCCTTGCCACAGAGTCCATGGTCCGCCGCCATGGACATTTCACAGTGGTCCGCCCCGAAGGGGGCGGGCGCAGCCTTCGAAGCGTACGCTCA............

 >NW_006725532.1 Balaenoptera acutorostrata scammoni unplaced genomic scaffold, BalAcu1.0 scaffold126, whole genome shotgun sequence
CGCGACCCAGATGGTCCAGGGAGCCCCTTCCATGACTGCGGGCGCCGGCGTCGCTGGGGGTCGTGTGTAAAGACAAAGGCTTCGTCTGCCTC.......................

 >DS547128.1 Laccaria bicolor S238N-H82 LACBIscaffold_38 genomic scaffold, whole genome shotgun sequence
AGGAGTTTGAAACGATTTGACCTTTGGCTGAATTATGCCACAACCGCTACACTCCGGGCCTCCAAATTTTGTGTGGTGGTGAATGTGTATCTCATGAACATGAATATATTTTTA..........

My query is that I just want to retain the sequences with keyword Hepatitis and want to delete the remaining entries. I would appreciate if somebody can suggest me the code to do so.

Thanks...

genome sequence

I added markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

@Pierre, Thanks for the link. Could find the answer......

1 answer

maybe can try to substitute the ID that start with symbol ">" to Hepatitis. You can do this in linux command

sed 's/^ >.*/Hepatitis/' < hepatitis.fasta  > NewIDHepatitis.fasta

OP wants to filter (keep) only the records from hepatitis, not rename everything to hepatitis...

Log in to answer this question.