Changing the format of a column in a file
1
0
Entering edit mode
19 months ago
munaj86 ▴ 30

Hi,

I have a file with the first column format of chr17:19111636-19113636 and I need to change it to this format chr17:19112636. The number 19112636 is basically either 19111636 + 1000 or 19113636 - 1000. These number represents the promoter regions in terms of TSS +/- 1000 kb. Any suggestions?

I attached the first few rows of the file

chr1    10869   12869   ENSG00000223972.5   ENST00000456328.2
chr1    11010   13010   ENSG00000223972.5   ENST00000450305.2
chr1    28570   30570   ENSG00000227232.5   ENST00000488147.1
chr1    16436   18436   ENSG00000278267.1   ENST00000619216.1
chr1    28554   30554   ENSG00000243485.5   ENST00000473358.1
chr1    29267   31267   ENSG00000243485.5   ENST00000469289.1
chr1    29366   31366   ENSG00000284332.1   ENST00000607096.1
chr1    35081   37081   ENSG00000237613.2   ENST00000417324.1
chr1    35073   37073   ENSG00000237613.2   ENST00000461467.1
chr1    51473   53473   ENSG00000268020.3   ENST00000606857.1
chr1    56598   58598   ENSG00000240361.2   ENST00000642116.1
chr1    61949   63949   ENSG00000240361.2   ENST00000492842.2
chr1    64419   66419   ENSG00000186092.5   ENST00000641515.1
chr1    68055   70055   ENSG00000186092.5   ENST00000335137.4
chr1    119932  121932  ENSG00000238009.6   ENST00000466430.5
chr1    128217  130217  ENSG00000238009.6   ENST00000477740.5

The desired output:

chr1:11869  ENSG00000223972.5   ENST00000456328.2
chr1:12010  ENSG00000223972.5   ENST00000450305.2

etc

Thanks

Linux • 493 views
ADD COMMENT
2
Entering edit mode
19 months ago
ATpoint 82k

You could at least try something, it's not a code writing service here.

Here for the lazy:

awk 'OFS="\t" {print $1":"$2+1000, $4, $5}'
ADD COMMENT
0
Entering edit mode

Thanks for this. I have a script that do this job but when I run it it gives me an error so I decided to look for a simple way rather than using a python script.

ADD REPLY

Login before adding your answer.

Traffic: 2678 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6