Extract maximum values for each objects from a file
0
votes
3
answers
215
views
I need to extract some values from a file in
bash
, on my CentOS system. In myfile.txt
I have a list of objects called Info_region
in which each object is identified with a code (eg. BARD1_region_005
or BIRC2_region_002
etc.) Moreover there are some others columns in which are reported some numerical variable. The same object (same code name) can be repeated several times in my file.
I also have a file that contains a completed list with all object codes without duplicates.
I would like to obtain an output.txt file in which each object (code name) is reported only once as in my list-file.txt and I would like to associate to this the maximum possible values associated with that code name in myfile.txt.
myfile.txt: (columns are separated by tab
)
Info_region Lig_score Lig_prevista Lig_prevista_+1 Int_score Expo_score Protac_score
BARD1_region_005 0 3 3 0 1 1
BARD1_region_006 0 1 1 0 1 1
BIRC2_region_001 1 6 7 0 1 2
BIRC2_region_001 1 7 8 0 1 2
BIRC2_region_001 0 2 2 0 0 0
BIRC2_region_001 0 12 12 0 1 1
BIRC2_region_001 1 10 11 -1 1 1
BIRC2_region_001 1 2 3 0 1 2
BIRC2_region_001 1 0 1 0 1 2
BIRC2_region_001 1 6 7 0 1 2
BIRC2_region_002 0 0 0 0 1 1
BIRC2_region_002 1 0 0 -1 0.5 0.5
BIRC2_region_003 0 0 0 0 1 1
BIRC2_region_004 0 1 1 0 1 1
UHRF1_region_004 0 0 0 1 1 2
UHRF1_region_004 0 0 0 1 1 2
UHRF1_region_004 1 0 1 0 0.5 1.5
UHRF1_region_004 0 0 0 1 1 2
UHRF1_region_005 0 3 3 1 1 2
UHRF1_region_005 1 0 0 -1 1 1
file-list.txt:
Info_region
BARD1_region_005
BARD1_region_006
BIRC2_region_001
BIRC2_region_002
BIRC2_region_003
BIRC2_region_004
UHRF1_region_004
UHRF1_region_005
output.txt:
Info_region Lig_score Lig_prevista Lig_prevista_+1 Int_score Expo_score Protac_score
BARD1_region_005 0 3 3 0 1 1
BARD1_region_006 0 1 1 0 1 1
BIRC2_region_001 1 12 12 0 1 2
BIRC2_region_002 1 0 0 0 1 1
BIRC2_region_003 0 0 0 0 1 1
BIRC2_region_004 0 1 1 0 1 1
UHRF1_region_004 1 0 1 1 1 2
UHRF1_region_005 1 3 3 1 1 2
Could someone help me please? Thank you!
Asked by Tommaso Palomba
(145 rep)
Apr 9, 2021, 11:05 AM
Last activity: Apr 9, 2021, 11:27 PM
Last activity: Apr 9, 2021, 11:27 PM