Edit table to create start and end position of recombination rate
1
0
Entering edit mode
23 months ago
Tine • 0

Hi,

I need to modify a number of very large tables. The tables contain recombination rates of each chromosome (ID) at specific positions.

The table has the structure: First column: ID; Second: Position; Third: Rate

Example input file

A 1 1.5

A 2 1.5

A 3 1.6

A 4 1.6

B 1 2.7

B 2 2.7

B 3 2.5

I would like to modify it into: First column: ID; Second: start position; Third: end position; Fourth: rate

Example output file

A 1 2 1.5

A 3 4 1.6

B 1 2 2.7

B 3 3 2.5

I usually edit my files using awk or sed, but I cannot figure out how to solve my problem. Help is much appreciated.

sed bash awk • 346 views
ADD COMMENT
0
Entering edit mode
23 months ago

As a seasoned user of awk or sed, you will certainly know, that both tools process files line by line.

So if you would like to combine information that is not on the same line, you have to change that beforehand: paste - - < file.txt | awk '...'

ADD COMMENT

Login before adding your answer.

Traffic: 2512 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