Question: Remove double vertical bar "||" at the end of the sequence in a fasta file
1
gravatar for Ambika
4 months 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 • 278 views
ADD COMMENTlink modified 4 months ago by SMK1.9k • written 4 months ago by Ambika30
6
gravatar for Pierre Lindenbaum
4 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum124k wrote:
sed 's/[\|]*$//' in.fasta
ADD COMMENTlink written 4 months ago by Pierre Lindenbaum124k
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 4 months ago by RamRS24k

Thanks you so much it works.

ADD REPLYlink written 4 months 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 4 months ago by genomax74k
4
gravatar for ATpoint
4 months ago by
ATpoint25k
Germany
ATpoint25k wrote:
awk '{gsub("\\|\\|","");print}' in.fasta
ADD COMMENTlink written 4 months ago by ATpoint25k
4
gravatar for Joe
4 months ago by
Joe14k
United Kingdom
Joe14k wrote:
cat file.fasta | tr -d '||' > fixed.fasta
ADD COMMENTlink modified 4 months ago • written 4 months ago by Joe14k
4
gravatar for SMK
4 months ago by
SMK1.9k
SMK1.9k wrote:
perl -pe 's/\|+$//' in.fasta
ADD COMMENTlink modified 4 months ago • written 4 months ago by SMK1.9k
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: 2089 users visited in the last hour