I have a dataset that consists of a bunch of elements (DNA sequences) that are compared in an all-against-all manner. In case it is relevant, the matches are not necessarily symmetric, so just because A matches B does not guarantee that B will match A. The output looks like this, where each line indicates a match between the sequence in column A and the sequence in column B based on my search criteria:
Contig1 Contig2 Contig1 Contig3 Contig2 Contig1 Contig2 Contig3 Contig3 Contig1 Contig3 Contig2 Contig3 Contig4 Contig4 Contig3 Contig4 Contig5 Contig6 Contig7 Contig7 Contig6 Contig8 Contig9 Contig9 Contig10 Contig10 Contig8 Contig10 Contig11 Contig11 Contig10
I want to divide this list into groups where a group consists of all the elements that are connected by at least one edge (including non-reciprocal edges). So in the example data, I would have three groups:
Group1: Contig1 Contig2 Contig3 Contig4 Contig5 Group2: Contig6 Contig7 Group3: Contig8 Contig9 Contig10 Contig11
I am at a lost to figure out an efficient way to do this in Perl, and any help would be greatly appreciated.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |