I’m very new to python, and having some difficulty getting hang of some more complicated things

I have multiple files which look like so:




Please be aware that the lines above are meant to be one file

I want to extract the EPI_ISL_000000 for an easy comparison among files.

Could someone please advise on:

  1. A programme to extract this data into new files (There’s many lines in each file - 1000+)

  2. A programme to then give a % comparison between two or more files - comparing all lines in one file against all lines in a second+ file

  • $\begingroup$ Anyway I get it, the first part is reg-ex, either via Python's re module, sed or a perl onliner. The second part, is easier to do in MEGA X. $\endgroup$
    – M__
    Oct 13, 2020 at 17:15
  • 1
    $\begingroup$ I have now figured this out, thank you! $\endgroup$
    – Theo Jones
    Oct 14, 2020 at 20:40
  • $\begingroup$ If you have figured it out please answer your own question and accept it. thank you. $\endgroup$
    – user438383
    Dec 1, 2020 at 10:34
  • $\begingroup$ I didn't study this subject... however, the percentage between two organisms may depend heavily on local protein aligniments and the same other active genetic material (because not active rna or not protein make rna has to have weight 0) $\endgroup$
    – RosLuP
    Dec 2, 2020 at 7:26
  • $\begingroup$ compile proteins of virus1 compile proteins of virus2 search % equality of proteins of the 2 viruses... or align the genome of 2 viruses and find uguagliance i don't know what number is more significative $\endgroup$
    – RosLuP
    Dec 11, 2020 at 18:10

1 Answer 1

   left_lineagelist = [x.split('_')[-1].split('|')[0] 
                          for x in left_lineagelist]
        right_lineagelist = set([x.split('_')[-1].split('|')[0] 
                          for x in right_lineagelist])

Allows for extraction of 6 digit EPI, provided the file has had sequences removed prior; as such:

for line in lines:
    if line[0] == '>':

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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