Question: Removing white space from the beginning of the second field (sequence) in a fasta file
0
gravatar for Angie11
27 days 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 • 126 views
ADD COMMENTlink modified 26 days ago by Chris Miller21k • written 27 days ago by Angie110
0
gravatar for bari.ballew
26 days ago by
bari.ballew190
USA/NIH
bari.ballew190 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 26 days ago by bari.ballew190
0
gravatar for Chris Miller
26 days 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 26 days 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: 856 users visited in the last hour