Visit Our UNIX and Linux User Community


Shorten header of protein sequences in fasta file to only organism name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shorten header of protein sequences in fasta file to only organism name
# 1  
Old 10-26-2019
Shorten header of protein sequences in fasta file to only organism name

I have a fasta file as follows

Code:
>sp|Q8WWQ8|STAB2_HUMAN Stabilin-2 OS=Homo sapiens OX=9606 GN=STAB2 PE=1 SV=3
MMLQHLVIFCLGLVVQNFCSPAETTGQARRCDRKSLLTIRTECRSCALNLGVKCPDGYTM
ITSGSVGVRDCRYTFEVRTYSLSLPGCRHICRKDYLQPRCCPGRWGPDCIECPGGAGSPC
NGRGSCAEGMEGNGTCSCQEGFGGTACETCADDNLFGPSCSSVCNCVHGVCNSGLDGDGT
CECYSAYTGPKCDKPIPECAALLCPENSRCSPSTEDENKLECKCLPNYRGDGKYCDPINP
CLRKICHPHAHCTYLGPNRHSCTCQEGYRGDGQVCLPVDPCQINFGNCPTKSTVCKYDGP
GQSHCECKEHYQNFVPGVGCSMTDICKSDNPCHRNANCTTVAPGRTECICQKGYVGDGLT
CYGNIMERLRELNTEPRGKWQGRLTSFISLLDKAYAWPLSKLGPFTVLLPTDKGLKGFNV
NELLVDNKAAQYFVKLHIIAGQMNIEYMNNTDMFYTLTGKSGEIFNSDKDNQIKLKLHGG
KKKVKIIQGDIIASNGLLHILDRAMDKLEPTFESNNEQTIMTMLQPRYSKFRSLLEETNL
GHALDEDGVGGPYTIFVPNNEALNNMKDGTLDYLLSPEGSRKLLELVRYHIVPFTQLEVA
TLISTPHIRSMANQLIQFNTTDNGQILANDVAMEEIEITAKNGRIYTLTGVLIPPSIVPI
LPHRCDETKREMKLGTCVSCSLVYWSRCPANSEPTALFTHRCVYSGRFGSLKSGCARYCN
ATVKIPKCCKGFYGPDCNQCPGGFSNPCSGNGQCADSLGGNGTCICEEGFQGSQCQFCSD
PNKYGPRCNKKCLCVHGTCNNRIDSDGACLTGTCRDGSAGRLCDKQTSACGPYVQFCHIH
ATCEYSNGT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VLMDASPRERLEGDLELLAVFTHVVVAVSVAALVLTAAILLSLRSLKSNVRGIHANVAA
ALGVAELLFLLGIHRTHNQLVCTAVAILLHYFFLSTFAWLFVQGLHLYRMQVEPRNVDRG
AMRFYHALGWGVPAVLLGLAVGLDPEGYGNPDFCWISVHEPLIWSFAGPVVLVIVMNGTM
FLLAARTSCSTGQREAKKTSALTLRSSFLLLLLVSASWLFGLLAVNHSILAFHYLHAGLC
GLQGLAVLLLFCVLNADARAAWMPACLGRKAAPEEARPAPGLGPGAYNNTALFEESGLIR
ITLGASTVSSVSSARSGRTQDQDSQRGRSYLRDNVLVRHGSAADHTDHSLQAHAGPTDLD
VAMFHRDAGADSDSDSDLSLEEERSLSIPSSESEDNGRTRGRFQRPLCRAAQSERLLTHP
KDVDGNDLLSYWPALGECEAAPCALQTWGSERRLGLDTSKDAANNNQPDPALTSGDETSL
GRAQRQRKGILKNRLQYPLVPQTRGAPELSWCRAATLGHRAVPAASYGRIYAGGGTGSLS
QPASRYSSREQLDLLLRRQLSRERLEEAPAPVLRPLSRPGSQECMDAAPGRLEPKDRGST
LPRRQPPRDYPGAMAGRFGSRDALDLGAPREWLSTLPPPRRTRDLDPQPPPLPLSPQRQL
SRDPLLPSRPLDSLSRSSNSREQLDQVPSRHPSREALGPLPQLLRAREDSVSGPSHGPST
EQLDILSSILASFNSSALSSVQSSSTPLGPHTTATPSATASVLGPSTPRSATSHSISELS
PDSEVPRSEGHS

I would like to shorten the header of each sequence so the header only contains the organism name e.g.

Code:
>Homo sapiens
MMLQHLVIFCLGLVVQNFCSPAETTGQARRCDRKSLLTIRTECRSCALNLGVKCPDGYTM
ITSGSVGVRDCRYTFEVRTYSLSLPGCRHICRKDYLQPRCCPGRWGPDCIECPGGAGSPC
NGRGSCAEGMEGNGTCSCQEGFGGTACETCADDNLFGPSCSSVCNCVHGVCNSGLDGDGT
CECYSAYTGPKCDKPIPECAALLCPENSRCSPSTEDENKLECKCLPNYRGDGKYCDPINP
CLRKICHPHAH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FYNDLVNGTTLQTR
LGSKLLITASQDPLQPTETRFVDGRAILQWDIFASNGIIHVISRPLKAPPAPVTLTHTGL
GAGIFFAIILVTGAVALAAYSYFRINRRTIGFQHFESEEDINVAALGKQQPENISNPLYE
STTSAPPEPSYDPFTDSEERQLEGNDPLRTL
>Homo sapiens
MMARRPPWRGLGGRSTPILLLLLLSLFPLSQEELGGGGHQGWDPGLAATTGPRAHIGGGA
LALCPESSGVREDGGPGLGVREPIFVGLRGRRQSARNSRGPPEQPNEELGIEHGVQPLGS
RERETGQGPGSVLYWRPEVSSCGRTGPLQRGSLSPGALSSGVPGSGNSSPLPSDFLIRHH
GPKPVSSQRNAGTGSRKRVGTARCCGELWATGSKGQGERATTSGAERTAPRRNCLPGASG
SGPELDSAPRTARTAPASGSAPRESRTAPEPAPKRMRSRGLFRCRFLPQRPGPRPPGLPA
RPEARKVTSANRARFRRAANRHPQFPQYNYQTLVPENEAAGTAVLRVVAQDPDAGEAGRL
VYSLAALMNSRSLELFSIDPQSGLIRTAAALDRESMERHYLRVTAQDHGSPRLSATTMVA
VTVADRNDHSPVFEQAQYRETLRENVEEGYPILQLRATDGDAPPNANLRYRFVGPPAARA
AAAAAFEIDPRSGLISTSGRVDREHMESYELVVEASDQGQEPGPRSATVRVHITVLDEND
NAPQFSEKRYVAQVREDVRPHTVVLRVTATDRDKDANGLVHYNIISGNSRGHFAIDSLTG
EIQVVAPLDFEAEREYALRIRAQDAGRPPLSNNTGLASIQVVDINDHIPIFVSTPFQVSV
LENAPLGHSVIHIQAVDADHGENARLEYSLTGVAPDTPFVINSATGWVSVSGPLDRESVE
HYFFGVEARDHGSPPLSASASVTVTVLDVNDNRPEFTMKEYHLRLNEDAAVGTSVVSVTA
VDRDANSAISYQITGGNTRNRFAISTQGGVGLVTLALPLDYKQERYFKLVLTASDRALHD
HCYVHINITDANTHRPVFQSAHYSVSVNEDRPMGSTIVVISASDDDVGENARITYLLEDN
LPQFRIDADSGAITLQAPLDYEDQVTYTLAITARD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LLRRQLSRERLEEAPAPVLRPLSRPGSQECMDAAPGRLEPKDRGST
LPRRQPPRDYPGAMAGRFGSRDALDLGAPREWLSTLPPPRRTRDLDPQPPPLPLSPQRQL
SRDPLLPSRPLDSLSRSSNSREQLDQVPSRHPSREALGPLPQLLRAREDSVSGPSHGPST
EQLDILSSILASFNSSALSSVQSSSTPLGPHTTATPSATASVLGPSTPRSATSHSISELS
PDSEVPRSEGHS

Any suggestions as to go about doing this?
# 2  
Old 10-26-2019
Hi, if the labels are always in that particular order, try:
Code:
sed '/^>/s/.*OS=\(.*\) OX=.*/\1/' file

Or if labels always only have uppercase names, followed by = signs, you could try:
Code:
sed '/^>/s/.*OS=\([^=]*\) [[:upper:]]\{1,\}=.*/\1/' file

# 3  
Old 10-26-2019
Thanks, would it be possible to retain the '>' at the header of each sequence?
# 4  
Old 10-26-2019
Yes, just put > before the back reference \1:
Code:
sed '/^>/s/.*OS=\(.*\) OX=.*/>\1/' file

These 2 Users Gave Thanks to Scrutinizer For This Post:

Previous Thread | Next Thread
Test Your Knowledge in Computers #246
Difficulty: Easy
By 1973, e-mail constituted 95% of the ARPANET traffic.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to add specific bases at the beginning and ending of all the fasta sequences?

Hi, I have to add 7 bases of specific nucleotide at the beginning and ending of all the fasta sequences of a file. For example, I have a multi fasta file namely test.fasta as given below test.fasta >TalAA18_Xoo_CIAT_NZ_CP033194.1:_2936369-2939570:+1... (1 Reply)
Discussion started by: dineshkumarsrk
1 Replies

2. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies

3. UNIX for Beginners Questions & Answers

How to count the length of fasta sequences?

I could calculate the length of entire fasta sequences by following command, awk '/^>/{if (l!="") print l; print; l=0; next}{l+=length($0)}END{print l}' unique.fasta But, I need to calculate the length of a particular fasta sequence specified/listed in another txt file. The results to to be... (14 Replies)
Discussion started by: dineshkumarsrk
14 Replies

4. Shell Programming and Scripting

Getting unique sequences from multiple fasta file

Hi, I have a fasta file with multiple sequences. How can i get only unique sequences from the file. For example my_file.fasta >seq1 TCTCAAAGAAAGCTGTGCTGCATACTGTACAAAACTTTGTCTGGAGAGATGGAGAATCTCATTGACTTTACAGGTGTGGACGGTCTTCAGAGATGGCTCAAGCTAACATTCCCTGACACACCTATAGGGAAAGAGCTAAC >seq2... (3 Replies)
Discussion started by: Ibk
3 Replies

5. UNIX for Dummies Questions & Answers

Fasta header modification

Hi, I need some help with modifying fasta headers. I have a fasta file with thousands of contigs and I need to modify their headers with the information obtained from a second file. File 1 contains the fasta sequences: >contig0001 length=11115 numreads=10777 agatgtagatctct... (6 Replies)
Discussion started by: Lokaps
6 Replies

6. UNIX for Dummies Questions & Answers

Select distinct sequences from fasta file and list

Hi How can I extract sequences from a fasta file with respect a certain criteria? The beginning of my file (containing in total more than 1000 sequences) looks like this: >H8V34IS02I59VP SDACNDLTIALLQIAREVRVCNPTFSFRWHPQVKDEVMRECFDCIRQGLG YPSMRNDPILIANCMNWHGHPLEEARQWVHQACMSPCPSTKHGFQPFRMA... (6 Replies)
Discussion started by: Marion MPI
6 Replies

7. Shell Programming and Scripting

Shorten header of protein sequences in fasta file

I have a fasta file as follows >sp|O15090|FABP4_HUMAN Fatty acid-binding protein, adipocyte OS=Homo sapiens GN=FABP4 PE=1 SV=3 MCDAFVGTWKLVSSENFDDYMKEVGVGFATRKVAGMAKPNMIISVNGDVITIKSESTFKN TEISFILGQEFDEVTADDRKVKSTITLDGGVLVHVQKWDGKSTTIKRKREDDKLVVECVM KGVTSTRVYERA >sp|L18484|AP2A2_RAT AP-2... (3 Replies)
Discussion started by: alexypaul
3 Replies

8. Shell Programming and Scripting

Extract sequences from a FASTA file based on another file

I have two files. File1 is shown below. >153L:B|PDBID|CHAIN|SEQUENCE RTDCYGNVNRIDTTGASCKTAKPEGLSYCGVSASKKIAERDLQAMDRYKTIIKKVGEKLCVEPAVIAGIISRESHAGKVL KNGWGDRGNGFGLMQVDKRSHKPQGTWNGEVHITQGTTILINFIKTIQKKFPSWTKDQQLKGGISAYNAGAGNVRSYARM DIGTTHDDYANDVVARAQYYKQHGY >16VP:A|PDBID|CHAIN|SEQUENCE... (7 Replies)
Discussion started by: nelsonfrans
7 Replies

9. Shell Programming and Scripting

Shell script for changing the accession number of DNA sequences in a FASTA file

Hi, I am having a file of dna sequences in fasta format which look like this: >admin_1_45 atatagcaga >admin_1_46 atatagcagaatatatat with many such thousands of sequences in a single file. I want to the replace the accession Id "admin_1_45" similarly in following sequences to... (5 Replies)
Discussion started by: margarita
5 Replies

10. Shell Programming and Scripting

script to shorten usernames and output to file

Hopefully someone here can point me in the correct direction. I'm working on a username migration and am trying to map my users ols usernames to the new ones. Right now every user has a username of firstname.lastname i.e. john.doe I'm trying to create a bash or python script that will take... (3 Replies)
Discussion started by: binary-ninja
3 Replies

Featured Tech Videos