Question: Removing white space from the beginning of the second field (sequence) in a fasta file
0
gravatar for Angie11
14 months ago by
Angie110
Angie110 wrote:

Hello,

Does anyone know of a command (in the linux command line) such as sed to remove white spaces from a specific field only? In my case, I have 2 tab-seperated fields in the format shown below and I would like to remove the white space from the beginning of the second field (the beginning of the sequence) without removing white spaces from the first field. It is a fasta format but I can convert it into a tab delimited text file if needed.

>10_GL0000024 root|cellular organisms|Bacteria|Firmicutes locus=scaffold18562_3:3421:4365:- [Complete]
 MELTFQTATPAERLYTTGQSMQIEGQMGYIGCLQTGMSEDGKGAFPKWSSGREGLNTEEFQQELAGVMDALIHDEQYGGFLKDSDAMRDFCQTHPESGFNNGFAFGFRADTAQYSYLIRLNPCKGEENLSICCYRRDWLDSHMKHAEKGIRFITPHYKEKFRIADGDKVRIRRFDGQVFDRVCRYIDDCHVEIGSELYHICQFAEIMERNGNSVIPLRSSLPFVCYGKVPEKRAIVMFERGFDGYRSASFATKGRTSQKLVDELNGELGVTKAQAAAMQGGATQGWASPAADPKNYDEQGQPIKPRHRDRGDAR

Thank you! Angie

linux protein sequence fasta • 631 views
ADD COMMENTlink modified 14 months ago by Chris Miller21k • written 14 months ago by Angie110
0
gravatar for bari.ballew
14 months ago by
bari.ballew230
USA/NIH
bari.ballew230 wrote:

Take a look at regex anchors, which tie your pattern to the beginning or end of a line. You can use sed to remove whitespace at the beginning of a line only using "^", which anchors the pattern to the beginning of the line.

sed 's/^[\t ]*//' file.fa > secondFile.fa
ADD COMMENTlink written 14 months ago by bari.ballew230
0
gravatar for Chris Miller
14 months ago by
Chris Miller21k
Washington University in St. Louis, MO
Chris Miller21k wrote:

if this is a fasta file, then you'll always want to remove leading whitespace, so something like:

sed 's/^\s//' myfile.fa

oughta work fine

ADD COMMENTlink written 14 months ago by Chris Miller21k
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: 1793 users visited in the last hour