Commit df2b2516 authored by peguerin's avatar peguerin
Browse files

rename genus into genus_taxid

parent 4051f8de
......@@ -55,9 +55,9 @@ def full_taxonomy_parents_sample(currentName, dfCure, reference, ncbi):
genID = GenID()
sample = Sample(sampleid="CUSTOM"+str(genID.id),
species_name=currentName,
genus=str(idGenus),
genus_taxid=str(idGenus),
genus_name=genusName,
family=str(idFamily),
family_taxid=str(idFamily),
family_name = familyName,
scientific_name = currentName,
taxid = genID.taxid,
......
......@@ -32,21 +32,20 @@ def add_newline_dmp(dmpDic, sample, mode):
then return the new line to add to nodes.dmp with the sample information
"""
try:
dmpNewLigne = dmpDic[sample.genus][0].copy()
dmpTaxid = sample.genus
dmpNewLigne = dmpDic[sample.genus_taxid][0].copy()
dmpTaxid = sample.genus_taxid
except KeyError:
try:
dmpNewLigne = dmpDic[sample.family][0].copy()
dmpTaxid = sample.family
dmpNewLigne = dmpDic[sample.family_taxid][0].copy()
dmpTaxid = sample.family_taxid
except KeyError:
print("FATAL ERROR: genus {0} family {1} not in {2}.dmp".format(sample.genus, sample.family, mode))
print("FATAL ERROR: genus {0} family {1} not in {2}.dmp".format(sample.genus_taxid, sample.family_taxid, mode))
if mode == "names":
dmpNewLigne[0] = str(sample.taxid)
dmpNewLigne[1] = str(sample.scientific_name.replace('_',' '))
dmpNewLigne[2] = ''
dmpNewLigne[3] = 'scientific name'+'\t|\n'
elif mode == "nodes":
#print(dmpDic[sample.genus])
dmpNewLigne[0] = str(sample.taxid)
dmpNewLigne[1] = str(dmpTaxid)
dmpNewLigne[2] = str(sample.rank)
......
......@@ -8,19 +8,19 @@ class GenID:
class Sample:
def __init__(self, sampleid, species_name, genus, genus_name, family, family_name, scientific_name, taxid, rank, context):
def __init__(self, sampleid, species_name, genus_taxid, genus_name, family_taxid, family_name, scientific_name, taxid, rank, context):
self.sampleid=sampleid
self.species_name=species_name
self.genus=genus
self.genus_taxid=genus_taxid
self.genus_name=genus_name
self.family=family
self.family_taxid=family_taxid
self.family_name=family_name
self.scientific_name=scientific_name
self.taxid=taxid
self.rank=rank
self.context = context
def description(self):
return "taxid={6}; species_name={0}; genus_taxid={8}; genus_name={1}; family_taxid={2}; family_name={3}; scientific_name={4}; rank={5}; {7}".format(self.species_name, self.genus_name, self.family, self.family_name, self.scientific_name, self.rank, self.taxid, self.context, self.genus)
return "taxid={6}; species_name={0}; genus_taxid={8}; genus_name={1}; family_taxid={2}; family_name={3}; scientific_name={4}; rank={5}; {7}".format(self.species_name, self.genus_name, self.family_taxid, self.family_name, self.scientific_name, self.rank, self.taxid, self.context, self.genus_taxid)
class DescriptionRecord:
def __init__(self, sampleid, species_name):
......
......@@ -117,9 +117,9 @@ def full_taxonomy_sample(sampleid, taxonid, ncbi, sampleContext):
speciesName = str(ncbi.translate_to_names([taxonid])[0])
sample = Sample(sampleid=sampleid,
species_name=speciesName,
genus=str(idGenus),
genus_taxid=str(idGenus),
genus_name=genusName,
family=str(idFamily),
family_taxid=str(idFamily),
family_name = familyName,
scientific_name = speciesName,
taxid = taxonid,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment