0

File 1

Name,TaxID,Lineage,Count,Proportion_All(%),Proportion_Classified(%)
Acaryochloris marina,155978,Bacteria;Cyanobacteria;;Synechococcales;Acaryochloridaceae;Acaryochloris,4,0.000218669,0.00120249
Anabaena cylindrica,1165,Bacteria;Cyanobacteria;;Nostocales;Nostocaceae;Anabaena,9,0.000492005,0.00270561

File 2

Object_ID, Length, Assignment
NODE_1_length_501653_cov_19.284,501653,1727163
NODE_2_length_458856_cov_17.1812,458856,374606
NODE_3_length_369230_cov_19.3769,369230,1727163
NODE_4_length_342860_cov_16.7318,342860,83263
NODE_5_length_301494_cov_19.1256,301494,1727163
NODE_6498_length_5833_cov_14.8079,5833,155978
NODE_6499_length_5833_cov_4.85133,5833,NA
NODE_6500_length_5831_cov_23.1697,5831,553814
NODE_6501_length_5831_cov_22.403,5831,795665

Output

Object_ID, Length, Assignment
NODE_6498_length_5833_cov_14.8079,5833,155978

ALl values in second column of File 1 matches the text in the very last array of File 2, if found, print File 2.

0

Using Awk:

awk -F, 'NR==FNR {TaxID[$2]=1; next} FNR==1 || $NF in TaxID' File1 File2
Object_ID, Length, Assignment
NODE_6498_length_5833_cov_14.8079,5833,155978
  • THANK YOU VERY MUCH FOR THIS ONE!!!! I was able to sort all the ones I need. – beth Oct 11 '18 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.