mirror of
https://codeberg.org/JasterV/sarscov-hierarchy.git
synced 2026-04-26 18:10:08 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e7ce5d46c5
7 changed files with 4 additions and 101 deletions
|
|
@ -15,7 +15,7 @@ pip install -r requeriments.txt 📝
|
|||
|
||||
### ✨ Execute
|
||||
|
||||
From the [NCBI official database](https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/virus?VirusLineage_ss=Severe%20acute%20respiratory%20syndrome%20coronavirus%202%20(SARS-CoV-2),%20taxid:2697049&SeqType_s=Nucleotide) download the sequences.fasta and sequences.csv files and you are ready to try this project!
|
||||
You must install the sequences.fasta and sequences.csv files rom the [NCBI official database](https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/virus?VirusLineage_ss=Severe%20acute%20respiratory%20syndrome%20coronavirus%202%20(SARS-CoV-2),%20taxid:2697049&SeqType_s=Nucleotide) to execute this project.
|
||||
|
||||
We provide you a .zip file with 2 other fasta and csv files to try out without downloading anything so, have fun!
|
||||
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
graph "Hierarchy Sars-Cov-2" {
|
||||
node [shape=plaintext]
|
||||
"Kazakhstan,South Africa" -- Kazakhstan
|
||||
"Kazakhstan,South Africa" -- "South Africa"
|
||||
"Kazakhstan,South Africa,Colombia" -- "Kazakhstan,South Africa"
|
||||
"Kazakhstan,South Africa,Colombia" -- Colombia
|
||||
"Jamaica,South Korea" -- Jamaica
|
||||
"Jamaica,South Korea" -- "South Korea"
|
||||
"Hong Kong,Viet Nam" -- "Hong Kong"
|
||||
"Hong Kong,Viet Nam" -- "Viet Nam"
|
||||
"France,Brazil" -- France
|
||||
"France,Brazil" -- Brazil
|
||||
"France,Brazil,Taiwan" -- "France,Brazil"
|
||||
"France,Brazil,Taiwan" -- Taiwan
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh" -- "Kazakhstan,South Africa,Colombia"
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh" -- Bangladesh
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay" -- "Kazakhstan,South Africa,Colombia,Bangladesh"
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay" -- Uruguay
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan" -- "Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay"
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan" -- "France,Brazil,Taiwan"
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam" -- "Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan"
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam" -- Guam
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka" -- "Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam"
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka" -- "Sri Lanka"
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland" -- "Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka"
|
||||
"Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland" -- Poland
|
||||
"Hong Kong,Viet Nam,Sweden" -- "Hong Kong,Viet Nam"
|
||||
"Hong Kong,Viet Nam,Sweden" -- Sweden
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea" -- "Hong Kong,Viet Nam,Sweden"
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea" -- "Jamaica,South Korea"
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland" -- "Hong Kong,Viet Nam,Sweden,Jamaica,South Korea"
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland" -- "Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland"
|
||||
"India,Australia" -- India
|
||||
"India,Australia" -- Australia
|
||||
"Israel,Peru" -- Israel
|
||||
"Israel,Peru" -- Peru
|
||||
"Japan,Greece" -- Japan
|
||||
"Japan,Greece" -- Greece
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands" -- "Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland"
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands" -- Netherlands
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China" -- "Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands"
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China" -- China
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown" -- "Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China"
|
||||
"Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown" -- Unknown
|
||||
"Japan,Greece,India,Australia" -- "Japan,Greece"
|
||||
"Japan,Greece,India,Australia" -- "India,Australia"
|
||||
"Japan,Greece,India,Australia,Spain" -- "Japan,Greece,India,Australia"
|
||||
"Japan,Greece,India,Australia,Spain" -- Spain
|
||||
"Puerto Rico,Czech Republic" -- "Puerto Rico"
|
||||
"Puerto Rico,Czech Republic" -- "Czech Republic"
|
||||
"USA,Turkey" -- USA
|
||||
"USA,Turkey" -- Turkey
|
||||
"Israel,Peru,Germany" -- "Israel,Peru"
|
||||
"Israel,Peru,Germany" -- Germany
|
||||
"Israel,Peru,Germany,USA,Turkey" -- "Israel,Peru,Germany"
|
||||
"Israel,Peru,Germany,USA,Turkey" -- "USA,Turkey"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal" -- "Israel,Peru,Germany,USA,Turkey"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal" -- Nepal
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown" -- "Israel,Peru,Germany,USA,Turkey,Nepal"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown" -- "Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain" -- "Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain" -- "Japan,Greece,India,Australia,Spain"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland" -- "Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland" -- Finland
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan" -- "Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan" -- Pakistan
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan,Puerto Rico,Czech Republic" -- "Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan,Puerto Rico,Czech Republic" -- "Puerto Rico,Czech Republic"
|
||||
"Iran,Philippines" -- Iran
|
||||
"Iran,Philippines" -- Philippines
|
||||
"Thailand,Italy" -- Thailand
|
||||
"Thailand,Italy" -- Italy
|
||||
"Thailand,Italy,Iran,Philippines" -- "Thailand,Italy"
|
||||
"Thailand,Italy,Iran,Philippines" -- "Iran,Philippines"
|
||||
"Tunisia,Nigeria" -- Tunisia
|
||||
"Tunisia,Nigeria" -- Nigeria
|
||||
"Tunisia,Nigeria,Thailand,Italy,Iran,Philippines" -- "Tunisia,Nigeria"
|
||||
"Tunisia,Nigeria,Thailand,Italy,Iran,Philippines" -- "Thailand,Italy,Iran,Philippines"
|
||||
"Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq" -- "Tunisia,Nigeria,Thailand,Italy,Iran,Philippines"
|
||||
"Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq" -- Iraq
|
||||
"Uzbekistan,Belgium" -- Uzbekistan
|
||||
"Uzbekistan,Belgium" -- Belgium
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan,Puerto Rico,Czech Republic,Malaysia" -- "Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan,Puerto Rico,Czech Republic"
|
||||
"Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan,Puerto Rico,Czech Republic,Malaysia" -- Malaysia
|
||||
"Uzbekistan,Belgium,Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq" -- "Uzbekistan,Belgium"
|
||||
"Uzbekistan,Belgium,Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq" -- "Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq"
|
||||
"Uzbekistan,Belgium,Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq,Serbia" -- "Uzbekistan,Belgium,Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq"
|
||||
"Uzbekistan,Belgium,Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq,Serbia" -- Serbia
|
||||
"Uzbekistan,Belgium,Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq,Serbia,Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan,Puerto Rico,Czech Republic,Malaysia" -- "Uzbekistan,Belgium,Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq,Serbia"
|
||||
"Uzbekistan,Belgium,Tunisia,Nigeria,Thailand,Italy,Iran,Philippines,Iraq,Serbia,Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan,Puerto Rico,Czech Republic,Malaysia" -- "Israel,Peru,Germany,USA,Turkey,Nepal,Hong Kong,Viet Nam,Sweden,Jamaica,South Korea,Kazakhstan,South Africa,Colombia,Bangladesh,Uruguay,France,Brazil,Taiwan,Guam,Sri Lanka,Poland,Netherlands,China,Unknown,Japan,Greece,India,Australia,Spain,Finland,Pakistan,Puerto Rico,Czech Republic,Malaysia"
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -21,7 +21,7 @@ def main():
|
|||
ids = csv_table.values('Accession')
|
||||
fasta_map = FastaMap(fasta_path).filter(lambda item: item[0] in ids)
|
||||
print("Files processing finished!")
|
||||
|
||||
|
||||
labels = csv_table.dict_of('Accession', 'Geo_Location')
|
||||
print("\nBuilding hierarchy...")
|
||||
distances_table = fasta_map.compare_all_samples()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from ete3 import Tree, TreeStyle
|
||||
from os import environ
|
||||
|
||||
environ['QT_QPA_PLATFORM']='offscreen'
|
||||
|
||||
class HierarchyTree:
|
||||
def __init__(self, table, labels=None):
|
||||
|
|
@ -16,17 +15,12 @@ class HierarchyTree:
|
|||
new_relation = self.build_relation(closest_pair, hierarchy_table)
|
||||
hierarchy_table = self.refactor_table(
|
||||
closest_pair, new_relation, hierarchy_table)
|
||||
self._show_tree(str(closest_pair))
|
||||
self._show_tree(f"({closest_pair})")
|
||||
|
||||
def _show_tree(self, tuple_repr):
|
||||
for key in self.__labels:
|
||||
tuple_repr = tuple_repr.replace(key, self.__labels[key])
|
||||
t = Tree(tuple_repr + ";")
|
||||
ts = TreeStyle()
|
||||
ts.show_leaf_name = True
|
||||
ts.mode = "c"
|
||||
ts.arc_start = -180 # 0 degrees = 3 o'clock
|
||||
ts.arc_span = 180
|
||||
print(t)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -36,7 +30,7 @@ class HierarchyTree:
|
|||
closest_id, distance = min(value.items(), key=lambda x: x[-1])
|
||||
closest_pairs.append((key, closest_id, distance))
|
||||
sample1, sample2, _ = min(closest_pairs, key=lambda x: x[-1])
|
||||
return sample1, sample2
|
||||
return sample2, sample1
|
||||
|
||||
@staticmethod
|
||||
def build_relation(pair, table):
|
||||
|
|
|
|||
Loading…
Reference in a new issue