0

I have a *.psl file in which there are 22 columns. I want to extract all rows on the basis of column 10 and column 22. SO as some have multiple common reads in column 10 and there is a score in column 22 so which have a higher score for a particular read just print those rows only and remove the remaining reads from my new output file.

98  1   0   0   0   0   0   0   +   7efcc799-5806-477b-8145-fb13d90fcdb4    466 151 250 hsa_circ_0005880    100 0   99  1   99, 151,    0,  99
98  1   0   0   0   0   0   0   +   7efcc799-5806-477b-8145-fb13d90fcdb4    466 151 250 hsa_circ_0005724    100 0   99  1   99, 151,    0,  99
98  1   0   0   0   0   0   0   +   7efcc799-5806-477b-8145-fb13d90fcdb4    466 151 250 hsa_circ_0005173    100 0   99  1   99, 151,    0,  99
97  1   0   0   0   0   0   0   +   7efcc799-5806-477b-8145-fb13d90fcdb4    466 152 250 hsa_circ_0004932    100 0   98  1   98, 152,    0,  98
94  0   0   0   1   3   2   6   +   4c415d86-0c12-4b07-ab19-0d7fcbe8b1c7    334 220 317 hsa_circ_0001006    100 0   100 3   18,25,51,   220,238,266,    0,19,49,    94
83  3   0   0   2   5   3   10  +   a28de8d0-e08b-43b5-9de2-07df4404ea8c    332 35  126 hsa_circ_0037060    100 4   100 5   7,18,43,3,15,   35,43,65,108,111,   4,11,36,81,85,  86
71  3   0   0   0   0   1   1   -   2116d815-5edb-4124-998b-398be6161c56    490 184 258 hsa_circ_0001592    100 1   76  2   34,40,  232,266,    1,36,   74

So I want output like this in which you can see one row is remove from my file which have low score than any other similar reads.

98  1   0   0   0   0   0   0   +   7efcc799-5806-477b-8145-fb13d90fcdb4    466 151 250 hsa_circ_0005880    100 0   99  1   99, 151,    0,  99
98  1   0   0   0   0   0   0   +   7efcc799-5806-477b-8145-fb13d90fcdb4    466 151 250 hsa_circ_0005724    100 0   99  1   99, 151,    0,  99
98  1   0   0   0   0   0   0   +   7efcc799-5806-477b-8145-fb13d90fcdb4    466 151 250 hsa_circ_0005173    100 0   99  1   99, 151,    0,  99
94  0   0   0   1   3   2   6   +   4c415d86-0c12-4b07-ab19-0d7fcbe8b1c7    334 220 317 hsa_circ_0001006    100 0   100 3   18,25,51,   220,238,266,    0,19,49,    94
83  3   0   0   2   5   3   10  +   a28de8d0-e08b-43b5-9de2-07df4404ea8c    332 35  126 hsa_circ_0037060    100 4   100 5   7,18,43,3,15,   35,43,65,108,111,   4,11,36,81,85,  86
71  3   0   0   0   0   1   1   -   2116d815-5edb-4124-998b-398be6161c56    490 184 258 hsa_circ_0001592    100 1   76  2   34,40,  232,266,    1,36,   74

I search it but there is no similar question I found. So please can you tell me how can I sort out this issue. Thanks in advance for your suggestions.

2
  • You could have provided an example demonstrating this problem with 5 columns instead of 30 (or whatever that is) necessitating a scroll bar. For future questions please create and post a minimal example for us to help you with, not just whatever data you have lying around.
    – Ed Morton
    Dec 23, 2021 at 13:35
  • It's not clear from your text (does which have a higher score mean which have the highest score or which have a score higher than the lowest score?) or your example which only removes 1 line if you want to remove all lines except those with the single highest score (keep lines for 1 score) or remove all lines with the single lowest score (potentially keep lines with multiple scores) or something else.
    – Ed Morton
    Dec 23, 2021 at 13:40

1 Answer 1

1

Using awk and processing the input file twice, once for finding the highest values for the same column10, and second time to printing the records with those highest values which we found:

awk 'NR==FNR{ max[$10]=(max[$10]>$NF? max[$10]:$NF); next } 
     max[$10]==$NF' infile infile

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .