Commit f0474e68 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE

cache in memory loaded records

parent 8fd8c923
......@@ -10,13 +10,33 @@ class StrainWrapped:
self.strain = strain.strip()
self.bio_sample = bio_sample.strip()
self.assembly = assembly.strip()
self.__bio_sample_sample_data_xml = None
self.__assembly_records = None
self.__sra_records = None
@property
def _bio_sample_sample_data(self):
if self.__bio_sample_sample_data_xml is not None:
return self.__bio_sample_sample_data_xml
sample_data = bio_sample_record(self.bio_sample)["DocumentSummarySet"]["DocumentSummary"][0]["SampleData"]
my_xml = fromstring(sample_data)
self.__bio_sample_sample_data_xml = my_xml
return my_xml
@property
def assembly_records(self):
if self.__assembly_records is not None:
return self.__assembly_records
self.__assembly_records = assembly_record(self.assembly)["DocumentSummarySet"]["DocumentSummary"]
return self.__assembly_records
@property
def sra_records(self):
if self.__sra_records is not None:
return self.__sra_records
self.__sra_records = sra_records(self.bio_sample)
return self.__sra_records
def get_bio_sample_attributes(self):
for attr in self._bio_sample_sample_data.iterfind(".//*[@attribute_name]"):
aka = set(attr.attrib.values())
......@@ -29,18 +49,18 @@ class StrainWrapped:
@property
def host(self):
return self._bio_sample_sample_data_attr("host")
return self.bio_sample_sample_data_attr("host")
@property
def location(self):
# where was obtained the sample, ville, hospital
return self._bio_sample_sample_data_attr("geo_loc_name")
return self.bio_sample_sample_data_attr("geo_loc_name")
@property
def isolation_date(self):
# date du prélévement
# return bio_sample_record(self.bio_sample)["DocumentSummarySet"]["DocumentSummary"][0]["Date"]
return self._bio_sample_sample_data_attr("collection_date")
return self.bio_sample_sample_data_attr("collection_date")
@property
def origin(self):
......@@ -50,7 +70,7 @@ class StrainWrapped:
@property
def coverage(self):
try:
return assembly_record(self.assembly)["DocumentSummarySet"]["DocumentSummary"][0]["Coverage"]
return self.assembly_records[0]["Coverage"]
except IndexError:
return None
......@@ -67,7 +87,7 @@ class StrainWrapped:
try:
my_xml = fromstringlist([
"<wrap>",
assembly_record(self.assembly)["DocumentSummarySet"]["DocumentSummary"][0]["Meta"],
self.assembly_records[0]["Meta"],
"</wrap>",
])
return ", ".join([node.text for node in my_xml.iterfind(".//assembly-status")])
......@@ -136,7 +156,7 @@ class StrainWrapped:
return None
def _sra_attrs(self, attr_name):
for entry in sra_records(self.bio_sample):
for entry in self.sra_records:
my_xml = fromstringlist([
"<wrap>",
entry["ExpXml"],
......
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