I need to convert a chain file that allows liftover from one reference to another (reference X-->Y) to one that would permit the reverse liftover (reference Y-->X). I thought that this would be as simple as swapping the second and third columns and making the corresponding adjustment to the header lines. This is what the Kent utilities program chainSwap does. However, downloading the files hg18ToHg19.over.chain.gz and hg19ToHg18.over.chain.gz shows that the program would not convert the hg18ToHg19 file into the hg19ToHg18 one. The first few lines of each file look like this:
hg18 --> hg19
chain 21270150726 chr1 247249719 + 0 247199719 chr1 249250621 + 10000 249233096 2
616 0 137
166664 50000 50000
40302 50000 50000
153649 50000 50000
1098446 269 272
773 1 1
hg19 --> hg18
chain 21270138829 chr1 249250621 + 10000 249233096 chr1 247249719 + 0 247199719 2
619 137 0
166661 50000 50000
40302 50000 50000
153649 50000 50000
1098479 1 1
47 1 1
Am I wrong in concluding that these chain files correspond to different ungapped interval mappings between the 2 references? I would interpret the hg18-->hg19 file as corresponding to the following interval mappings:
- [0, 616) --> [10000, 10616)
- [616, 167280) --> [10753, 177417)
- [217280, 257582) --> [227417, 267719)
- [307582, 461231) --> [317719, 471368)
- [511231, 1609677) --> [521368, 1619814)
- [1609946, 1610719) --> [1620086, 1620859)
while the hg19-->hg18 file would correspond to the following interval mappings:
- [10000, 10619) --> [0, 619)
- [10756, 177417) --> [619, 167280)
- [227417, 267719) --> [217280, 257582)
- [317719, 471368) --> [307582, 461231)
- [521368, 1619847), --> [511231, 1609710)
- [1619848, 1619895) --> [1609711, 1609758)
where square bracket [ denotes an interval containing the boundary and parentheses (denotes an interval excluding the boundary. I would have thought that these intervals mappings should be the same. Am I missing something here? Is there a good general approach for switching the direction of the chain file?
Thanks!
chain-files
alignment
liftover