1
$\begingroup$

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:

hCoV-19/Singapore/4/2020|EPI_ISL_410535|2020-02-03

hCoV-19/USA/WA13-UW9/2020|EPI_ISL_413601|2020-03-02

hCoV-19/USA/WA-UW142/2020|EPI_ISL_416680|2020-03-11

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

$\endgroup$
5
  • $\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__
    Commented Oct 13, 2020 at 17:15
  • 1
    $\begingroup$ I have now figured this out, thank you! $\endgroup$
    – Theo Jones
    Commented 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
    Commented 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
    Commented 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
    Commented Dec 11, 2020 at 18:10

1 Answer 1

0
$\begingroup$
   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] == '>':
        print(line[1:])
$\endgroup$

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.