Question: sed or awk command
0
gravatar for harry
5 weeks ago by
harry0
harry0 wrote:
ENST00000448914.1   13  4.28456     0       0
ENST00000415118.1   8   3.52171     0       0

how to remove the (.*) from column 1 and it looks like

ENST00000448914 13  4.28456     0       0
ENST00000415118     8   3.52171     0       0

please tell me the sed command or awk command to remove it only .

rna-seq • 156 views
ADD COMMENTlink modified 5 weeks ago by SMK1.8k • written 5 weeks ago by harry0
2
gravatar for SMK
5 weeks ago by
SMK1.8k
SMK1.8k wrote:

Hi harry,

By awk:

awk 'BEGIN{OFS="\t"} {gsub("\\.[0-9]+$", "", $1); print}'

(updated) For sed you can try:

sed -r 's/\.[0-9]+\t/\t/'
ADD COMMENTlink modified 5 weeks ago • written 5 weeks ago by SMK1.8k
0
gravatar for lakhujanivijay
5 weeks ago by
lakhujanivijay4.3k
India
lakhujanivijay4.3k wrote:

Hi harry

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.
code_formatting

You could try sed like this

sed 's/\.1//'
ADD COMMENTlink written 5 weeks ago by lakhujanivijay4.3k

This would only address .1s. We should account for .\d+, right?

ADD REPLYlink written 5 weeks ago by RamRS23k
0
gravatar for darbinator
5 weeks ago by
darbinator190
darbinator190 wrote:

If the gene is always on the first column:

sed 's/\.[0-9]\{1,\}//' yourfile.txt

should work

ADD COMMENTlink modified 5 weeks ago • written 5 weeks ago by darbinator190

it will remove other (.) from other column.

ADD REPLYlink written 5 weeks ago by harry0

It's weird because I try it and it don't remove the others (.) because I didn't put the 'g' global flag after the last slash

ADD REPLYlink written 5 weeks ago by darbinator190

It might if the first . it encounters is not the transcript version. The awk solution, or yours modified to include an anchor and a first-word ensuring regex would be safe.

ADD REPLYlink written 5 weeks ago by RamRS23k
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: 1616 users visited in the last hour