I have a space separated file like this:(it has 1775 lines)
head output.fam 0 ALIKE_g_1LTX827_BI_SNP_F01_33250.CEL 0 0 0 -9 0 BURRY_g_3KYJ479_BI_SNP_A12_40182.CEL 0 0 0 -9 0 ABAFT_g_4RWG569_BI_SNP_E12_35136.CEL 0 0 0 -9 0 MILLE_g_5AVC089_BI_SNP_F02_35746.CEL 0 0 0 -9 0 PEDAL_g_8WWR250_BI_SNP_B06_37732.CEL 0 0 0 -9 ...
and a comma separated file phg000008.individualinfo (that has 1838 lines):
#Phen_Sample_ID - individual sample name associated with phenotypes #Geno_Sample_ID - sample name associates with genotypes #Ind_id - unique individual name which can be used to match duplicates (in this case same as Phen_Sample_ID) #Ped_id - Pedigree ID #Fa_id - Father individual ID #Ma_id - Mother individual ID #Sex - coded 1 for Male, 2 for Female #Ind_QC_flag - value "ALL" indicates released in both Quality Filtered and Complete set #Genotyping_Plate #Sample_plate_well_string - This string corresponds to the file within the CEL files distribution #Genotype_Clustering_Set #Study-id - dbGaP assigned study id #Phen_ID,Geno_Sample_ID,Ind_id,Ped_id,Fa_id,Ma_id,Sex,Ind_QC_flag,Genotyping_Plate,Sample_plate_well_string,Genotyping_Clustering_Set,Study_id G1000,G1000,G1000,fam1000-,0,0,2,ALL,7FDZ321,POSED_g_7FDZ321_BI_SNP_B02_36506,set05,phs000018 G1001,G1001,G1001,fam1001-,G4243,G4205,1,ALL,3KYJ479,BURRY_g_3KYJ479_BI_SNP_H04_40068,set02,phs000018 G2208,G2208,G2208,fam2208-,G3119,G3120,2,ALL,1LTX827,ALIKE_g_1LTX827_BI_SNP_F01_33250,set01,phs000018 G1676,G1676,G1676,fam1676-,G1675,G1674,1,ALL,3KYJ479,BURRY_g_3KYJ479_BI_SNP_A12_40182,set02,phs000018 ...
I would like to change my output.fam by looking if I could find value from the 2nd column in output.fam, say ALIKE_g_1LTX827_BI_SNP_F01_33250.CEL in phg000008.individualinfo (disregarding .CEL suffix) and is there is a row with that entry replace that entry in output.fam with the value in the first column of phg000008.individualinfo and also for the same line replace the value of the first column of output.fam with the value in the 4th column of phg000008.individualinfo (excluding - suffix)
So for example for two lines, output.fam would look like this:
fam2208 G2208 0 0 0 -9 fam1676 G1676 0 0 0 -9