Skip to content
This repository was archived by the owner on Aug 19, 2020. It is now read-only.

Commit bf1de43

Browse files
authored
Merge pull request #236 from jkbaumohl/develop
Added the new fields to the saving of the summary object
2 parents cecc5f5 + 554aff3 commit bf1de43

File tree

1 file changed

+24
-10
lines changed
  • lib/doekbase/data_api/annotation/genome_annotation

1 file changed

+24
-10
lines changed

lib/doekbase/data_api/annotation/genome_annotation/api.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ def save_summary(self):
508508
Args:
509509
None
510510
Returns:
511-
bool - Success/Failure
511+
tuple (first element bool - Success/Failure, 2nd element is python summary object-
512+
(Done so if do not have permissions to write to the ws, the summary object can still be retrieved))
512513
"""
513514
pass
514515

@@ -2493,6 +2494,19 @@ def save_summary(self):
24932494

24942495
summary_object["feature_counts_map"] = self.get_feature_type_counts()
24952496

2497+
summary_object["assembly_ref"] = self.get_data_subset(path_list=["assembly_ref"])["assembly_ref"]
2498+
summary_object["taxon_ref"] = self.get_data_subset(path_list=["taxon_ref"])["taxon_ref"]
2499+
2500+
try:
2501+
alias_source_dict = self.get_data_subset(path_list=["alias_source_counts_map"])["alias_source_counts_map"]
2502+
summary_object["alias_sources"] = alias_source_dict.keys()
2503+
except:
2504+
summary_object["alias_sources"] = list()
2505+
2506+
proteins = dict()
2507+
proteins = self.get_proteins()
2508+
summary_object["cds_coding_for_proteins_count"] = len(proteins)
2509+
24962510
summary_provenance = [
24972511
{
24982512
"script": __file__,
@@ -2515,22 +2529,22 @@ def save_summary(self):
25152529
}
25162530
]
25172531
})
2518-
return True
2532+
return True, summary_object
25192533
except Exception, e:
2520-
return False
2534+
print("WS Save Summary Error: {0}".format(e))
2535+
return False, summary_object
25212536

25222537
def get_summary(self):
25232538
refs = self.get_referrers()
25242539
all_summary_types = sorted([t for t in refs if t.startswith("KBaseGenomeAnnotations.GenomeAnnotationSummary")])
25252540

25262541
if len(all_summary_types) == 0:
2527-
self.save_summary()
2528-
refs = self.get_referrers()
2529-
all_summary_types = sorted([t for t in refs if t.startswith("KBaseGenomeAnnotations.GenomeAnnotationSummary")])
2530-
2531-
# the highest version type will be last, and there should only ever be one summary object per version
2532-
latest_summary = refs[all_summary_types[-1]][0]
2533-
summary = ObjectAPI(self.services, self._token, latest_summary).get_data()
2542+
save_summary_result = self.save_summary()
2543+
summary = save_summary_result[1]
2544+
else:
2545+
# the highest version type will be last, and there should only ever be one summary object per version
2546+
latest_summary = refs[all_summary_types[-1]][0]
2547+
summary = ObjectAPI(self.services, self._token, latest_summary).get_data()
25342548

25352549
out = {
25362550
"taxonomy": {

0 commit comments

Comments
 (0)