perl merging data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lilly07
    New Member
    • Jul 2008
    • 89

    #1

    perl merging data

    Hi I need to merge my data as below and its highly confusing and please let me know how to do.

    Code:
    3       131835844       131835943       3       131830073       131830172
    18      33659786        33659885        18      33653576        33653675
    2       146593375       146593474       2       146578884       146578983
    3       83938058        83938157        3       83935615        83935714
    4       46493910        46494009        4       46491549        46491648
    6       66318803        66318902        6       66316635        66316734
    7       157824010       157824109       7       157822909       157823008
    21      46629155        46629254        21      46626285        46626384
    1       244751925       244752024       1       244749678       244749777
    I have to merge my data of every line as below:
    For every line,
    If ($col1Line1 eq $col4Line2) {

    if($col2Line2 lies between $col2Line1 and $col3Line1 or ($col3Line2 lies between $col2Line1 and $col3Line1) && ($col5Line2 lies between $col5Line1 and $col6Line1 or ($col5Line2 lies between $col5Line1 and $col6Line1) {
    $merge line 1 and 2 and make it as a line with outer most $col2, $col3, $col5 and $col6
    }

    }

    Basically I want to merge data into clusters with overlapping from both the ends. The comparison needs to be done against all the records and merge them into bigger clusters.

    If I write a very biginners way of writing the above conditions, it might take a longer time to finish the job too. It would be really really great if someone could help in this? Thanks.
Working...