本文整理汇总了Python中src.sgd.model.nex.UpdateByJsonMixin.to_json方法的典型用法代码示例。如果您正苦于以下问题:Python UpdateByJsonMixin.to_json方法的具体用法?Python UpdateByJsonMixin.to_json怎么用?Python UpdateByJsonMixin.to_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.sgd.model.nex.UpdateByJsonMixin
的用法示例。
在下文中一共展示了UpdateByJsonMixin.to_json方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_json
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def to_json(self):
obj_json = UpdateByJsonMixin.to_json(self)
obj_json['reference'] = None if self.reference is None else self.reference.to_json()
obj_json['datasetcolumns'] = [x.to_min_json() for x in self.datasetcolumns]
obj_json['tags'] = [x.tag.to_min_json() for x in self.bioitem_tags]
obj_json['urls'] = [x.to_min_json() for x in self.urls]
return obj_json
示例2: convert
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def convert(self, newly_created_obj):
if self.commit_interval is not None and (self.added_count + self.updated_count + self.deleted_count) % self.commit_interval == 0:
self.session.commit()
if newly_created_obj is None:
self.none_count += 1
return 'None'
key = newly_created_obj.unique_key()
if key not in self.keys_already_seen:
self.keys_already_seen.add(key)
current_obj_json = None if key not in self.key_to_current_obj_json else self.key_to_current_obj_json[key]
newly_created_obj_json = UpdateByJsonMixin.to_json(newly_created_obj)
if current_obj_json is None:
if newly_created_obj.id in self.current_obj_ids:
current_obj_by_id = self.current_obj_query(self.session).filter_by(id=newly_created_obj.id).first()
self.session.delete(current_obj_by_id)
self.session.add(newly_created_obj)
self.added_count += 1
return 'Added'
elif newly_created_obj.compare(current_obj_json):
current_obj = self.current_obj_query(self.session).filter_by(id=current_obj_json['id']).first()
if current_obj is not None:
current_obj.update(newly_created_obj_json)
self.updated_count += 1
return 'Updated'
else:
self.error_count += 1
return 'Error'
else:
self.no_change_count += 1
return 'No Change'
else:
self.duplicate_count += 1
return 'Duplicate'
示例3: to_json
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def to_json(self):
obj_json = UpdateByJsonMixin.to_json(self)
obj_json["references"] = [x.reference.to_min_json() for x in self.alias_references]
if self.category in {
"PDB identifier",
"UniParc ID",
"UniProtKB/Swiss-Prot ID",
"UniProtKB/TrEMBL ID",
"UniProtKB Subcellular Location",
"Protein version ID",
"EC number",
"InterPro ID",
"RefSeq protein version ID",
"RefSeq nucleotide version ID",
"TPA protein version ID",
"DNA version ID",
"protein GI",
"TPA Accession ID",
"PDB ID",
"RefSeq Accession ID",
"TC number",
"PANTHER",
}:
obj_json["protein"] = True
else:
obj_json["protein"] = False
return obj_json
示例4: to_json
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def to_json(self):
obj_json = UpdateByJsonMixin.to_json(self)
new_obj_json = {'id': obj_json['id']}
for key, value in obj_json.iteritems():
if key != 'id':
new_obj_json[key] = value == 1
return new_obj_json
示例5: to_json
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def to_json(self):
obj_json = UpdateByJsonMixin.to_json(self)
obj_json['locus_count'] = self.locus_count
obj_json['descendant_locus_count'] = self.descendant_locus_count
obj_json['urls'] = [x.to_json() for x in sorted(self.urls, key=lambda x: x.display_name)]
obj_json['aliases'] = [x.display_name for x in sorted(self.aliases, key=lambda x: x.display_name)]
return obj_json
示例6: to_json
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def to_json(self):
obj_json = UpdateByJsonMixin.to_json(self)
obj_json['references'] = [x.reference.to_min_json() for x in self.alias_references]
if self.category in {'PDB identifier', 'UniParc ID', 'UniProt/Swiss-Prot ID', 'UniProt/TrEMBL ID',
'UniProtKB Subcellular Location', 'Protein version ID', 'EC number', 'InterPro', 'RefSeq protein version ID',
'RefSeq nucleotide version ID', 'TPA protein version ID', 'DNA version ID', 'NCBI protein GI', 'TPA Accession',
'PDB ID', 'RefSeq Accession', 'TC number', 'PANTHER'}:
obj_json['protein'] = True
else:
obj_json['protein'] = False
return obj_json
示例7: to_json
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def to_json(self, linkit=False):
obj_json = UpdateByJsonMixin.to_json(self)
obj_json["references"] = sorted(
[x.reference.to_semi_json() for x in self.paragraph_references],
key=lambda x: (x["year"], x["pubmed_id"]),
reverse=True,
)
if linkit:
obj_json["text"] = obj_json["html"]
del obj_json["html"]
return obj_json
示例8: to_json
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def to_json(self):
obj_json = UpdateByJsonMixin.to_json(self)
obj_json['abstract'] = None if len(self.paragraphs) == 0 else self.paragraphs[0].to_json(linkit=True)
obj_json['bibentry'] = None if self.bibentry is None else self.bibentry.text
obj_json['reftypes'] = [x.reftype.to_min_json() for x in self.ref_reftypes]
obj_json['authors'] = [x.author.to_min_json() for x in self.author_references]
interaction_locus_ids = set()
interaction_locus_ids.update([x.locus1_id for x in self.physinteraction_evidences])
interaction_locus_ids.update([x.locus2_id for x in self.physinteraction_evidences])
interaction_locus_ids.update([x.locus1_id for x in self.geninteraction_evidences])
interaction_locus_ids.update([x.locus2_id for x in self.geninteraction_evidences])
regulation_locus_ids = set()
regulation_locus_ids.update([x.locus1_id for x in self.regulation_evidences])
regulation_locus_ids.update([x.locus2_id for x in self.regulation_evidences])
obj_json['urls'] = [x.to_min_json() for x in self.urls]
obj_json['counts'] = {
'interaction': len(interaction_locus_ids),
'go': len(set([x.locus_id for x in self.go_evidences])),
'phenotype': len(set([x.locus_id for x in self.phenotype_evidences])),
'regulation': len(regulation_locus_ids)
}
obj_json['related_references'] = []
for child in self.children:
child_json = child.child.to_semi_json()
child_json['abstract'] = None if len(child.child.paragraphs) == 0 else child.child.paragraphs[0].to_json(linkit=True)
child_json['reftypes'] = [x.reftype.to_min_json() for x in child.child.ref_reftypes]
obj_json['related_references'].append(child_json)
for parent in self.parents:
parent_json = parent.parent.to_semi_json()
parent_json['abstract'] = None if len(parent.parent.paragraphs) == 0 else parent.parent.paragraphs[0].to_json(linkit=True)
parent_json['reftypes'] = [x.reftype.to_min_json() for x in parent.parent.ref_reftypes]
obj_json['related_references'].append(parent_json)
obj_json['urls'] = [x.to_json() for x in self.urls]
if self.journal is not None:
obj_json['journal']['med_abbr'] = self.journal.med_abbr
id_to_dataset = {}
for expression_evidence in self.expression_evidences:
if expression_evidence.datasetcolumn.dataset_id not in id_to_dataset:
id_to_dataset[expression_evidence.datasetcolumn.dataset_id] = expression_evidence.datasetcolumn.dataset
obj_json['expression_datasets'] = [x.to_semi_json() for x in id_to_dataset.values()]
return obj_json
示例9: __init__
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def __init__(self, session_maker, current_obj_query, name=None, commit_interval=None, commit=False, delete_untouched=False, already_deleted=0):
self.session = session_maker()
self.current_obj_query = current_obj_query
self.name = name
self.commit_interval = commit_interval
self.commit = commit
self.delete_untouched = delete_untouched
self.key_to_current_obj_json = dict()
self.current_obj_ids = set()
for obj in current_obj_query(self.session):
self.key_to_current_obj_json[obj.unique_key()] = UpdateByJsonMixin.to_json(obj)
self.current_obj_ids.add(obj.id)
self.keys_already_seen = set()
self.none_count = 0
self.added_count = 0
self.updated_count = 0
self.no_change_count = 0
self.duplicate_count = 0
self.error_count = 0
self.deleted_count = already_deleted
示例10: to_json
# 需要导入模块: from src.sgd.model.nex import UpdateByJsonMixin [as 别名]
# 或者: from src.sgd.model.nex.UpdateByJsonMixin import to_json [as 别名]
def to_json(self):
obj_json = UpdateByJsonMixin.to_json(self)
# Phenotype overview
phenotype_paragraphs = [x.to_json() for x in self.paragraphs if x.category == "PHENOTYPE"]
classical_groups = dict()
large_scale_groups = dict()
strain_groups = dict()
for evidence in self.phenotype_evidences:
if evidence.experiment.category == "classical genetics":
if evidence.mutant_type in classical_groups:
if evidence.phenotype_id not in classical_groups[evidence.mutant_type]:
classical_groups[evidence.mutant_type][evidence.phenotype_id] = evidence.phenotype
else:
classical_groups[evidence.mutant_type] = {evidence.phenotype_id: evidence.phenotype}
elif evidence.experiment.category == "large-scale survey":
if evidence.mutant_type in large_scale_groups:
if evidence.phenotype_id not in large_scale_groups[evidence.mutant_type]:
large_scale_groups[evidence.mutant_type][evidence.phenotype_id] = evidence.phenotype
else:
large_scale_groups[evidence.mutant_type] = {evidence.phenotype_id: evidence.phenotype}
if evidence.strain is not None:
if evidence.strain.display_name in strain_groups:
strain_groups[evidence.strain.display_name] += 1
else:
strain_groups[evidence.strain.display_name] = 1
experiment_categories = []
mutant_types = set(classical_groups.keys())
mutant_types.update(large_scale_groups.keys())
for mutant_type in mutant_types:
experiment_categories.append(
[
mutant_type,
0 if mutant_type not in classical_groups else len(classical_groups[mutant_type]),
0 if mutant_type not in large_scale_groups else len(large_scale_groups[mutant_type]),
]
)
strains = []
for strain, count in strain_groups.iteritems():
strains.append([strain, count])
experiment_categories.sort(key=lambda x: x[1] + x[2], reverse=True)
experiment_categories.insert(0, ["Mutant Type", "classical genetics", "large-scale survey"])
strains.sort(key=lambda x: x[1], reverse=True)
strains.insert(0, ["Strain", "Annotations"])
obj_json["phenotype_overview"] = {
"paragraph": None if len(phenotype_paragraphs) == 0 else phenotype_paragraphs[0]["text"],
"experiment_categories": experiment_categories,
"strains": strains,
"classical_phenotypes": dict(
[(x, [phenotype.to_min_json() for phenotype in y.values()]) for x, y in classical_groups.iteritems()]
),
"large_scale_phenotypes": dict(
[(x, [phenotype.to_min_json() for phenotype in y.values()]) for x, y in large_scale_groups.iteritems()]
),
}
# Go overview
man_mf = dict()
man_bp = dict()
man_cc = dict()
htp_mf = dict()
htp_bp = dict()
htp_cc = dict()
for evidence in self.go_evidences:
goterm = evidence.go
ev_json = None
if goterm.go_aspect == "molecular function" and evidence.annotation_type == "manually curated":
if goterm.id not in man_mf:
man_mf[goterm.id] = {"term": goterm.to_min_json(), "evidence_codes": [], "qualifiers": []}
ev_json = man_mf[goterm.id]
elif goterm.go_aspect == "molecular function" and evidence.annotation_type == "high-throughput":
if goterm.id not in htp_mf:
htp_mf[goterm.id] = {"term": goterm.to_min_json(), "evidence_codes": [], "qualifiers": []}
ev_json = htp_mf[goterm.id]
elif goterm.go_aspect == "biological process" and evidence.annotation_type == "manually curated":
if goterm.id not in man_bp:
man_bp[goterm.id] = {"term": goterm.to_min_json(), "evidence_codes": [], "qualifiers": []}
ev_json = man_bp[goterm.id]
elif goterm.go_aspect == "biological process" and evidence.annotation_type == "high-throughput":
if goterm.id not in htp_bp:
htp_bp[goterm.id] = {"term": goterm.to_min_json(), "evidence_codes": [], "qualifiers": []}
ev_json = htp_bp[goterm.id]
elif goterm.go_aspect == "cellular component" and evidence.annotation_type == "manually curated":
if goterm.id not in man_cc:
man_cc[goterm.id] = {"term": goterm.to_min_json(), "evidence_codes": [], "qualifiers": []}
ev_json = man_cc[goterm.id]
elif goterm.go_aspect == "cellular component" and evidence.annotation_type == "high-throughput":
if goterm.id not in htp_cc:
htp_cc[goterm.id] = {"term": goterm.to_min_json(), "evidence_codes": [], "qualifiers": []}
ev_json = htp_cc[goterm.id]
if ev_json is not None:
if evidence.experiment_id is not None:
evidence_code_ids = [x["id"] for x in ev_json["evidence_codes"]]
#.........这里部分代码省略.........