Question: Remove double vertical bar "||" at the end of the sequence in a fasta file
1
gravatar for Ambika
19 days ago by
Ambika30
United States/Auburn/Auburn University
Ambika30 wrote:

Hello I have a fasta file as

>jgi|FusspF23_1|104542
GGTTCTCTTGTCTGTTTTTAAAAGAGTCTCGAGACCCC||
>jgi|FusspF23_1|10121
GGGGCCGCCCTCGATTCATCAGCGAAATTGCTCAGTCGGGCG||

at the end of fasta sequence I have these symbols "||" which I want to remove. I tried using sed but in that way I will end up removing that symbol "|" in fasta sequence description line ">jgi|FusspF23_1|104542" which I don't want.

Please help.

Thank you, Ambika

awk sed fasta • 184 views
ADD COMMENTlink modified 19 days ago by SMK1.8k • written 19 days ago by Ambika30
6
gravatar for Pierre Lindenbaum
19 days ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum121k wrote:
sed 's/[\|]*$//' in.fasta
ADD COMMENTlink written 19 days ago by Pierre Lindenbaum121k
2

We could also have sed match the first character of a line and replace only when the line does not start with a >:

sed '/^[^>]/s/|//g' in.fasta
ADD REPLYlink written 18 days ago by RamRS22k

Thanks you so much it works.

ADD REPLYlink written 18 days ago by Ambika30

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
Upvote|Bookmark|Accept

ADD REPLYlink written 18 days ago by genomax69k
4
gravatar for ATpoint
19 days ago by
ATpoint19k
Germany
ATpoint19k wrote:
awk '{gsub("\\|\\|","");print}' in.fasta
ADD COMMENTlink written 19 days ago by ATpoint19k
4
gravatar for jrj.healey
19 days ago by
jrj.healey13k
United Kingdom
jrj.healey13k wrote:
cat file.fasta | tr -d '||' > fixed.fasta
ADD COMMENTlink modified 19 days ago • written 19 days ago by jrj.healey13k
4
gravatar for SMK
19 days ago by
SMK1.8k
Ghent, Belgium
SMK1.8k wrote:
perl -pe 's/\|+$//' in.fasta
ADD COMMENTlink modified 19 days ago • written 19 days ago by SMK1.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 932 users visited in the last hour