Question: sed or awk command
0
gravatar for harry
11 months ago by
harry10
harry10 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 • 285 views
ADD COMMENTlink modified 11 months ago by SMK1.9k • written 11 months ago by harry10
2
gravatar for SMK
11 months ago by
SMK1.9k
SMK1.9k 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 11 months ago • written 11 months ago by SMK1.9k
0
gravatar for lakhujanivijay
11 months ago by
lakhujanivijay5.1k
India
lakhujanivijay5.1k 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 11 months ago by lakhujanivijay5.1k

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

ADD REPLYlink written 11 months ago by RamRS27k
0
gravatar for darbinator
11 months ago by
darbinator220
darbinator220 wrote:

If the gene is always on the first column:

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

should work

ADD COMMENTlink modified 11 months ago • written 11 months ago by darbinator220

it will remove other (.) from other column.

ADD REPLYlink written 11 months ago by harry10

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 11 months ago by darbinator220

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 11 months ago by RamRS27k
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: 1173 users visited in the last hour