Hi . I have a .txt file (660 rows) like this :
Locations Animals
chr1:10934871-10991498 MAZ4 DLS5 AFS33
chr1:113630180-113698152 AL108 BDP358 MFW157 MFW160 MAZ4
chr1:131662885-131770719 MAZ4
chr1:133496547-133547227 FINN306 MAZ4
chr1:134599444-134663260 MAZ4 DLS5 AFS33 AL108 BDP358 MFW157 MFW160 FINN306
chr1:135686897-135790910 FINN306
chr1:145754786-147013267 MFW157 MFW160
chr1:147927373-148035506 MAZ4
How can I change it, like this:
MAZ4
chr1:131662885-131770719
chr1:134599444-134663260
chr1:147927373-148035506
chr1:113630180-113698152
chr1:10934871-10991498
DLS5
chr1:10934871-10991498
chr1:134599444-134663260
AFS33
chr1:134599444-134663260
chr1:10934871-10991498
AL108
chr1:113630180-113698152
chr1:134599444-134663260
BDP358
chr1:134599444-134663260
chr1:113630180-113698152
MFW157
chr1:113630180-113698152
chr1:134599444-134663260
chr1:145754786-147013267
MFW160
chr1:134599444-134663260
chr1:113630180-113698152
chr1:145754786-147013267
FINN306
chr1:133496547-133547227
chr1:135686897-135790910
chr1:134599444-134663260
Actually I want to classify animals based on their locations. Please help me, Thanks.
We highly appreciate that you try something first before we help.
One solution, take any text manipulation language you want, like Perl or Python
Create a dictionnary (key, value)
For every line of your .txt file, save new animal as key.
For each new key create an array as value and append the associated location to this array
At the end you will have animals as keys in your dictionnary and the associated locations as values
Print the dictionnary as you want. Good luck
Note : Maybe possible in one command line in awk for tryharders
Thanks for your attention
What are the delimiters between the columns (I assume tab) and between the animals (I assume whitespace)?
Yes, of course. You are right.