I need to parse this file with a REGEX so that it returns ONE close relative of a gene of interest and the gene of interest (does not matter which one).The sequence the comes first is the close relative. The gene of interest in parentheses. I want to exclude lines that are a repeat of the same sequence.
Metan1_4283(Metac1_3189) Metac1_3189(Metac1_3189) MagorCD156_00067621(MagorUS71_00075311) MagorUS71_00075311(MagorUS71_00075311) Phaca1_206503(Phchr2_2932727) Phchr2_2932727(Phchr2_2932727) Thiar1_121068(Thiar1_121068) Thite2_36710(Thiar1_121068) Chagl1_10753(Thiar1_121068) Spoth2_41043(Thiar1_121068) Myche1_767736(Thiar1_121068) Thiar1_767720(Thiar1_767720) Spoth2_47778(Thiar1_767720) Myche1_701010(Thiar1_767720) Sorma1_06886(Thiar1_767720) Neudi1_90877(Thiar1_767720) Neutemata1_106297(Thiar1_767720) NeutematA2_74860(Thiar1_767720) Neucrtrp31_8476(Thiar1_767720) Neucr2_8476(Thiar1_767720) Thian1_368754(Thiar1_767720) Thiap1_682895(Thiar1_767720) Thihy1_418088(Thiar1_767720) Podan2_4187(Thiar1_767720) Micmi1_478558(Micmi1_478558) Micmi1_311120(Micmi1_478558) Micmi1_478558(Micmi1_311120) Micmi1_311120(Micmi1_311120)
For example I want to end up with something like this below
Metan1_4283 : Metac1_3189 MagorCD156_00067621 : MagorUS71_00075311 Phaca1_206503 : Phchr2_2932727 Thite2_36710 : Thiar1_121068 Spoth2_47778 : Thiar1_767720 Micmi1_311120 : Micmi1_478558 Micmi1_478558 : Micmi1_311120

In reply to Perl regex by Nicpetbio23!

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.