本文整理汇总了Python中dipper.models.Model.Model.addType方法的典型用法代码示例。如果您正苦于以下问题:Python Model.addType方法的具体用法?Python Model.addType怎么用?Python Model.addType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dipper.models.Model.Model
的用法示例。
在下文中一共展示了Model.addType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _add_snp_to_graph
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
def _add_snp_to_graph(
self, snp_id, snp_label, chrom_num, chrom_pos, context,
risk_allele_frequency=None):
# constants
tax_id = 'NCBITaxon:9606'
genome_version = 'GRCh38'
if self.testMode:
g = self.testgraph
else:
g = self.graph
model = Model(g)
if chrom_num != '' and chrom_pos != '':
location = self._make_location_curie(chrom_num, chrom_pos)
if location not in self.id_location_map:
self.id_location_map[location] = set()
else:
location = None
alteration = re.search(r'-(.*)$', snp_id)
if alteration is not None \
and re.match(r'[ATGC]', alteration.group(1)):
# add variation to snp
pass # TODO
if location is not None:
self.id_location_map[location].add(snp_id)
# create the chromosome
chrom_id = makeChromID(chrom_num, genome_version, 'CHR')
# add the feature to the graph
snp_description = None
if risk_allele_frequency is not None\
and risk_allele_frequency != ''\
and risk_allele_frequency != 'NR':
snp_description = \
str(risk_allele_frequency) + \
' [risk allele frequency]'
f = Feature(
g, snp_id, snp_label.strip(),
Feature.types['SNP'], snp_description)
if chrom_num != '' and chrom_pos != '':
f.addFeatureStartLocation(chrom_pos, chrom_id)
f.addFeatureEndLocation(chrom_pos, chrom_id)
f.addFeatureToGraph()
f.addTaxonToFeature(tax_id)
# TODO consider adding allele frequency as property;
# but would need background info to do that
# also want to add other descriptive info about
# the variant from the context
for c in re.split(r';', context):
cid = self._map_variant_type(c.strip())
if cid is not None:
model.addType(snp_id, cid)
return
示例2: _add_snp_to_graph
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
def _add_snp_to_graph(
self, snp_id, snp_label, chrom_num, chrom_pos, context,
risk_allele_frequency=None):
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model(graph)
if chrom_num != '' and chrom_pos != '':
location = self._make_location_curie(chrom_num, chrom_pos)
if location not in self.id_location_map:
self.id_location_map[location] = set()
else:
location = None
alteration = re.search(r'-(.*)$', snp_id)
if alteration is not None and re.match(r'[ATGC]', alteration.group(1)):
# add variation to snp
pass # TODO
if location is not None:
self.id_location_map[location].add(snp_id)
# create the chromosome
chrom_id = makeChromID(chrom_num, self.localtt['reference assembly'], 'CHR')
# add the feature to the graph
snp_description = None
if risk_allele_frequency is not None\
and risk_allele_frequency != ''\
and risk_allele_frequency != 'NR':
snp_description = str(risk_allele_frequency) + ' [risk allele frequency]'
feat = Feature(
graph, snp_id, snp_label.strip(), self.globaltt['SNP'], snp_description)
if chrom_num != '' and chrom_pos != '':
feat.addFeatureStartLocation(chrom_pos, chrom_id)
feat.addFeatureEndLocation(chrom_pos, chrom_id)
feat.addFeatureToGraph()
feat.addTaxonToFeature(self.globaltt['Homo sapiens'])
# TODO consider adding allele frequency as property;
# but would need background info to do that
# also want to add other descriptive info about
# the variant from the context
for ctx in re.split(r';', context):
ctx = ctx.strip()
cid = self.resolve(ctx, False)
if cid != ctx:
model.addType(snp_id, cid)
return
示例3: Genotype
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
#.........这里部分代码省略.........
self.graph.addTriple(parent_id, part_relationship, part_id)
return
def addSequenceAlteration(
self, sa_id, sa_label, sa_type=None, sa_description=None):
if sa_type is None:
sa_type = self.genoparts['sequence_alteration']
self.model.addIndividualToGraph(
sa_id, sa_label, sa_type, sa_description)
return
def addSequenceAlterationToVariantLocus(self, sa_id, vl_id):
self.addParts(sa_id, vl_id, self.properties['has_alternate_part'])
return
def addGenomicBackground(
self, background_id, background_label,
background_type=None, background_description=None):
if background_type is None:
background_type = self.genoparts['genomic_background']
self.model.addIndividualToGraph(
background_id, background_label, background_type,
background_description)
return
def addGenomicBackgroundToGenotype(
self, background_id, genotype_id, background_type=None):
if background_type is None:
background_type = self.genoparts['genomic_background']
self.model.addType(background_id, background_type)
self.addParts(background_id, genotype_id,
self.object_properties['has_reference_part'])
return
def addTaxon(self, taxon_id, genopart_id):
"""
The supplied geno part will have the specified taxon added with
RO:in_taxon relation.
Generally the taxon is associated with a genomic_background,
but could be added to any genotype part (including a gene,
regulatory element, or sequence alteration).
:param taxon_id:
:param genopart_id:
:return:
"""
self.graph.addTriple(
genopart_id, self.properties['in_taxon'], taxon_id)
return
def addGeneTargetingReagentToGenotype(self, reagent_id, genotype_id):
# for example, add a morphant reagent thingy to the genotype,
# assuming it's a extrinsic_genotype
self.graph.addTriple(
genotype_id, self.properties['has_variant_part'], reagent_id)
return
def addGeneTargetingReagent(
示例4: OBAN
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
#.........这里部分代码省略.........
# this is going to be used for the refactored evidence/provenance
self.provenance = []
self.score = None
self.score_type = None
self.score_unit = None
return
def get_properties(self):
return self.properties
def _is_valid(self):
# check if sub/obj/rel are none...throw error
if self.sub is None:
raise ValueError('No subject set for this association')
if self.obj is None:
raise ValueError('No object set for this association')
if self.rel is None:
raise ValueError('No relation set for this association')
return True
def _add_basic_association_to_graph(self):
if not self._is_valid():
return
self.graph.addTriple(self.sub, self.rel, self.obj)
if self.assoc_id is None:
self.set_association_id()
self.model.addType(self.assoc_id, self.assoc_types['association'])
self.graph.addTriple(
self.assoc_id, self.object_properties['has_subject'], self.sub)
self.graph.addTriple(
self.assoc_id, self.object_properties['has_object'], self.obj)
self.graph.addTriple(
self.assoc_id, self.object_properties['has_predicate'], self.rel)
if self.description is not None:
self.model.addDescription(self.assoc_id, self.description)
if self.evidence is not None and len(self.evidence) > 0:
for e in self.evidence:
self.graph.addTriple(
self.assoc_id, self.object_properties['has_evidence'], e)
if self.source is not None and len(self.source) > 0:
for s in self.source:
if re.match('http', s):
# TODO assume that the source is a publication?
# use Reference class here
self.graph.addTriple(
self.assoc_id, self.object_properties['has_source'],
s, True)
else:
self.graph.addTriple(
self.assoc_id, self.object_properties['has_source'], s)
if self.provenance is not None and len(self.provenance) > 0:
for p in self.provenance:
self.graph.addTriple(
self.assoc_id, self.object_properties['has_provenance'], p)
示例5: Feature
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
#.........这里部分代码省略.........
if add_region:
# create a region that has the begin/end positions
regionchr = re.sub(r'\w+\:_?', '', self.start['reference'])
if region_id is None:
# in case the values are undefined
# if we know only one of the coordinates,
# then we'll add an "unknown" other.
st = sp = 'UN'
strand = None
if self.start is not None and self.start['coordinate'] is not None:
st = str(self.start['coordinate'])
strand = self._getStrandStringFromPositionTypes(self.start['type'])
if self.stop is not None and self.stop['coordinate'] is not None:
sp = str(self.stop['coordinate'])
if strand is not None:
strand = self._getStrandStringFromPositionTypes(
self.stop['type'])
# assume that the strand is the same for both start and stop.
# this will need to be fixed in the future
region_items = [regionchr, st, sp]
if strand is not None:
region_items += [strand]
region_id = '-'.join(region_items)
rid = region_id
rid = re.sub(r'\w+\:', '', rid, 1) # replace the id prefix
rid = '_:'+rid+"-Region"
region_id = rid
self.graph.addTriple(self.fid, self.globaltt['location'], region_id)
self.model.addIndividualToGraph(region_id, None, self.globaltt['Region'])
else:
region_id = self.fid
self.model.addType(region_id, self.globaltt['region'])
# add the start/end positions to the region
beginp = endp = None
if self.start is not None:
beginp = self._makePositionId(
self.start['reference'], self.start['coordinate'], self.start['type'])
self.addPositionToGraph(
self.start['reference'], self.start['coordinate'], self.start['type'])
if self.stop is not None:
endp = self._makePositionId(
self.stop['reference'], self.stop['coordinate'], self.stop['type'])
self.addPositionToGraph(
self.stop['reference'], self.stop['coordinate'], self.stop['type'])
self.addRegionPositionToGraph(region_id, beginp, endp)
# {coordinate : integer, reference : reference_id, types = []}
return
def _getStrandStringFromPositionTypes(self, tylist):
strand = None
if self.globaltt['plus_strand'] in tylist:
strand = 'plus'
elif self.globaltt['minus_strand'] in tylist:
strand = 'minus'
elif self.globaltt['both_strand'] in tylist:
strand = 'both'
else:
strand = None # it is stranded, but we don't know what it is
示例6: __init__
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
#.........这里部分代码省略.........
self.ref_url = None
self.title = None
self.year = None
self.author_list = None
self.short_citation = None
self.model = Model(self.graph)
self.globaltt = self.graph.globaltt
self.globaltcid = self.graph.globaltcid
self.curie_map = self.graph.curie_map
if ref_type is None:
self.ref_type = self.globaltt['document']
else:
self.ref_type = ref_type
if ref_type[:4] not in ('IAO:', 'SIO:'):
LOG.warning("Got Pub ref type of: %s", ref_type)
if ref_id is not None and ref_id[:4] == 'http':
self.ref_url = ref_id
return
def setTitle(self, title):
self.title = title
return
def setYear(self, year):
self.year = year
return
def setType(self, reference_type):
self.ref_type = reference_type
return
def setAuthorList(self, author_list):
"""
:param author_list: Array of authors
:return:
"""
self.author_list = author_list
return
def addAuthor(self, author):
self.author_list += [author]
return
def setShortCitation(self, citation):
self.short_citation = citation
return
def addPage(self, subject_id, page_url):
self.graph.addTriple(
subject_id, self.globaltt['page'], # foaf:page not <sio:web page>
page_url, object_is_literal=True)
return
def addTitle(self, subject_id, title):
if title is not None and title != '':
self.graph.addTriple(
subject_id, self.globaltt['title (dce)'], title, object_is_literal=True)
return
def addRefToGraph(self):
cite = self.short_citation
if cite is None and self.title is not None:
cite = self.title
if self.ref_url is not None:
if self.title is not None:
self.addTitle(self.ref_url, self.title)
self.model.addType(self.ref_url, self.ref_type)
if cite is not None:
self.model.addLabel(self.ref_url, cite)
elif self.ref_id is not None:
self.model.addIndividualToGraph(self.ref_id, cite, self.ref_type)
if self.title is not None:
self.addTitle(self.ref_id, self.title)
else:
# should never be true
LOG.error("You are missing an identifier for a reference.")
# TODO what is the property here to add the date?
# if self.year is not None:
# gu.addTriple()
# if self.author_list is not None:
# for auth in self.author_list:
# gu.addTriple(
# graph, self.ref_id, self.props['has_author'], auth, True)
return
示例7: _process_data
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
#.........这里部分代码省略.........
if locus_num is not None and locus_num not in omim_map:
omim_map[locus_num] = [var_num]
else:
omim_map[locus_num] += [var_num]
for omim in omim_map:
# gene_id = 'OMIM:' + omim # TODO unused
vslc_id = '_:' + '-'.join(
[omim + '.' + a for a in omim_map.get(omim)])
vslc_label = varl
# we don't really know the zygosity of
# the alleles at all.
# so the vslcs are just a pot of them
model.addIndividualToGraph(
vslc_id, vslc_label,
self.globaltt['variant single locus complement'])
for var in omim_map.get(omim):
# this is actually a sequence alt
allele1_id = 'OMIM:' + omim + '.' + var
geno.addSequenceAlteration(allele1_id, None)
# assume that the sa -> var_loc -> gene
# is taken care of in OMIM
geno.addPartsToVSLC(
vslc_id, allele1_id, None,
self.globaltt['indeterminate'],
self.globaltt['has_variant_part'])
if vslc_id != gvc_id:
geno.addVSLCtoParent(vslc_id, gvc_id)
if affected == 'unaffected':
# let's just say that this person is wildtype
model.addType(patient_id, self.globaltt['wildtype'])
elif genotype_id is None:
# make an anonymous genotype id (aka blank node)
genotype_id = '_:geno' + catalog_id.strip()
# add the gvc
if gvc_id is not None:
model.addIndividualToGraph(
gvc_id, gvc_label,
self.globaltt['genomic_variation_complement'])
# add the gvc to the genotype
if genotype_id is not None:
if affected == 'unaffected':
rel = self.globaltt['has_reference_part']
else:
rel = self.globaltt['has_variant_part']
geno.addParts(gvc_id, genotype_id, rel)
if karyotype_id is not None \
and self._is_normal_karyotype(karyotype):
if gvc_label is not None and gvc_label != '':
genotype_label = '; '.join((gvc_label, karyotype))
elif karyotype is not None:
genotype_label = karyotype
if genotype_id is None:
genotype_id = karyotype_id
else:
geno.addParts(
karyotype_id, genotype_id,
self.globaltt['has_reference_part'])
else:
genotype_label = gvc_label
示例8: Feature
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
#.........这里部分代码省略.........
if region_id is None:
# in case the values are undefined
# if we know only one of the coordinates,
# then we'll add an "unknown" other.
st = sp = 'UN'
strand = None
if self.start is not None and \
self.start['coordinate'] is not None:
st = str(self.start['coordinate'])
strand = self._getStrandStringFromPositionTypes(
self.start['type'])
if self.stop is not None and\
self.stop['coordinate'] is not None:
sp = str(self.stop['coordinate'])
if strand is not None:
strand = self._getStrandStringFromPositionTypes(
self.stop['type'])
# assume that the strand is the same for both start and stop.
# this will need to be fixed in the future
region_items = [regionchr, st, sp]
if strand is not None:
region_items += [strand]
region_id = '-'.join(region_items)
rid = region_id
rid = re.sub(r'\w+\:', '', rid, 1) # replace the id prefix
rid = '_:'+rid+"-Region"
region_id = rid
self.graph.addTriple(self.id, self.properties['location'],
region_id)
self.model.addIndividualToGraph(region_id, None, 'faldo:Region')
else:
region_id = self.id
self.model.addType(region_id, 'faldo:Region')
# add the start/end positions to the region
beginp = endp = None
if self.start is not None:
beginp = self._makePositionId(self.start['reference'],
self.start['coordinate'],
self.start['type'])
self.addPositionToGraph(self.start['reference'],
self.start['coordinate'],
self.start['type'])
if self.stop is not None:
endp = self._makePositionId(self.stop['reference'],
self.stop['coordinate'],
self.stop['type'])
self.addPositionToGraph(self.stop['reference'],
self.stop['coordinate'],
self.stop['type'])
self.addRegionPositionToGraph(region_id, beginp, endp)
# {coordinate : integer, reference : reference_id, types = []}
return
def _getStrandStringFromPositionTypes(self, tylist):
strand = None
if self.types['plus_strand'] in tylist:
strand = 'plus'
elif self.types['minus_strand'] in tylist:
strand = 'minus'
elif self.types['both_strand'] in tylist:
示例9: OBAN
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
class Assoc:
"""
A base class for OBAN (Monarch)-style associations,
to enable attribution of source and evidence
on statements.
"""
def __init__(self, graph, definedby, sub=None, obj=None, pred=None):
if isinstance(graph, Graph):
self.graph = graph
else:
raise ValueError("{} is not a graph".format(graph))
self.model = Model(self.graph)
self.globaltt = self.graph.globaltt
self.globaltcid = self.graph.globaltcid
self.curie_map = self.graph.curie_map
# core parts of the association
self.definedby = definedby
self.sub = sub
self.obj = obj
self.rel = pred
self.assoc_id = None
self.description = None
self.source = []
self.evidence = []
self.date = []
# this is going to be used for the refactored evidence/provenance
self.provenance = []
self.score = None
self.score_type = None
self.score_unit = None
return
def _is_valid(self):
# check if sub/obj/rel are none...raise error
if self.sub is None:
raise ValueError(
'No subject set for this association <%s> <%s> <%s>',
self.sub, self.rel, self.obj
)
if self.obj is None:
raise ValueError(
'No object set for this association <%s> <%s> <%s>',
self.sub, self.rel, self.obj
)
if self.rel is None:
raise ValueError(
'No predicate set for this association <%s> <%s> <%s>',
self.sub, self.rel, self.obj
)
# Are subject & predicate, either a curie or IRI
pfx = self.sub.split(':')[0]
if pfx not in self.curie_map.keys() and \
pfx not in ['_', 'http', 'https', 'ftp']:
raise ValueError(
'Invalid Subject for this association <%s> <%s> <%s>',
self.sub, self.rel, self.obj
)
pfx = self.rel.split(':')[0]
if pfx not in self.curie_map.keys() and \
pfx not in ['_', 'http', 'https', 'ftp']:
raise ValueError(
'Invalid Predicate for this association <%s> <%s> <%s>',
self.sub, self.rel, self.obj
)
return True
def add_association_to_graph(self):
if not self._is_valid():
return
self.graph.addTriple(self.sub, self.rel, self.obj)
if self.assoc_id is None:
self.set_association_id()
assert self.assoc_id is not None
self.model.addType(self.assoc_id, self.model.globaltt['association'])
self.graph.addTriple(
self.assoc_id, self.globaltt['association has subject'], self.sub)
self.graph.addTriple(
self.assoc_id, self.globaltt['association has object'], self.obj)
self.graph.addTriple(
self.assoc_id, self.globaltt['association has predicate'], self.rel)
if self.description is not None:
self.model.addDescription(self.assoc_id, self.description)
if self.evidence is not None and len(self.evidence) > 0:
for evi in self.evidence:
self.graph.addTriple(self.assoc_id, self.globaltt['has evidence'], evi)
if self.source is not None and len(self.source) > 0:
#.........这里部分代码省略.........
示例10: _process_data
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
#.........这里部分代码省略.........
allele2_label = re.sub(r'<.*', '<+>', allele1_label)
allele2_id = None
elif zygosity == 'homozygote':
allele2_label = allele1_label
allele2_id = allele1_id
allele2_rel = self.globaltt['has_variant_part']
elif zygosity == 'hemizygote':
allele2_label = re.sub(r'<.*', '<0>', allele1_label)
allele2_id = None
elif zygosity == 'not_applicable':
allele2_label = re.sub(r'<.*', '<?>', allele1_label)
allele2_id = None
else:
LOG.warning("found unknown zygosity %s", zygosity)
break
vslc_name = '/'.join((allele1_label, allele2_label))
# Add the VSLC
vslc_id = '-'.join(
(marker_accession_id, allele_accession_id, zygosity))
vslc_id = re.sub(r':', '', vslc_id)
vslc_id = '_:'+vslc_id
model.addIndividualToGraph(
vslc_id, vslc_name,
self.globaltt['variant single locus complement'])
geno.addPartsToVSLC(
vslc_id, allele1_id, allele2_id, zygosity_id,
self.globaltt['has_variant_part'], allele2_rel)
# add vslc to genotype
geno.addVSLCtoParent(vslc_id, genotype_id)
# note that the vslc is also the gvc
model.addType(vslc_id, self.globaltt['genomic_variation_complement'])
# Add the genomic background
# create the genomic background id and name
if strain_accession_id != '':
genomic_background_id = strain_accession_id
else:
genomic_background_id = None
genotype_name = vslc_name
if genomic_background_id is not None:
geno.addGenotype(
genomic_background_id, strain_name,
self.globaltt['genomic_background'])
# make a phenotyping-center-specific strain
# to use as the background
pheno_center_strain_label = strain_name + '-' + phenotyping_center \
+ '-' + colony_raw
pheno_center_strain_id = '-'.join((
re.sub(r':', '', genomic_background_id),
re.sub(r'\s', '_', phenotyping_center),
re.sub(r'\W+', '', colony_raw)))
if not re.match(r'^_', pheno_center_strain_id):
# Tag bnode
pheno_center_strain_id = '_:' + pheno_center_strain_id
geno.addGenotype(
pheno_center_strain_id, pheno_center_strain_label,
self.globaltt['genomic_background'])
geno.addSequenceDerivesFrom(
pheno_center_strain_id, genomic_background_id)
示例11: __init__
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
class Dataset:
"""
this will produce the metadata about a dataset
following the example laid out here:
http://htmlpreview.github.io/?
https://github.com/joejimbo/HCLSDatasetDescriptions/blob/master/Overview.html#appendix_1
(mind the wrap)
"""
def __init__(self, identifier, title, url, description=None,
license_url=None, data_rights=None, graph_type=None,
file_handle=None):
if graph_type is None:
self.graph = RDFGraph(None, identifier) #
elif graph_type == 'streamed_graph':
self.graph = StreamedGraph(True, file_handle=file_handle)
elif graph_type == 'rdf_graph':
self.graph = RDFGraph()
self.model = Model(self.graph)
self.identifier = ':' + identifier
self.version = None
self.date_issued = None
# The data_accesed value is later used as an literal of properties
# such as dct:issued, which needs to conform xsd:dateTime format.
# TODO ... we need to have a talk about typed literals and SPARQL
self.date_accessed = datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
self.citation = set()
self.license = license_url
self.model.addType(self.identifier, 'dctypes:Dataset')
self.graph.addTriple(self.identifier, 'dct:title', title, True)
self.graph.addTriple(
self.identifier, 'dct:identifier',
identifier, object_is_literal=True)
self.graph.addTriple(self.identifier, 'foaf:page', url)
# maybe in the future add the logo here:
# schemaorg:logo <http://www.ebi.ac.uk/rdf/sites/ebi.ac.uk.rdf/files/resize/images/rdf/chembl_service_logo-146x48.gif> .
# TODO add the licence info
# FIXME:Temporarily making this in IF statement,
# can revert after all current resources are updated.
if license_url is not None:
self.graph.addTriple(
self.identifier, 'dct:license', license_url)
else:
logger.debug('No license provided.')
if data_rights is not None:
self.graph.addTriple(
self.identifier, 'dct:rights',
data_rights, object_is_literal=True)
else:
logger.debug('No rights provided.')
if description is not None:
self.model.addDescription(self.identifier, description)
return
def setVersion(self, date_issued, version_id=None):
"""
Legacy function...
should use the other set_* for version and date
as of 2016-10-20 used in:
dipper/sources/HPOAnnotations.py 139:
dipper/sources/CTD.py 99:
dipper/sources/BioGrid.py 100:
dipper/sources/MGI.py 255:
dipper/sources/EOM.py 93:
dipper/sources/Coriell.py 200:
dipper/sources/MMRRC.py 77:
# TODO set as deprecated
:param date_issued:
:param version_id:
:return:
"""
if date_issued is not None:
self.set_date_issued(date_issued)
elif version_id is not None:
self.set_version_by_num(version_id)
else:
logger.error("date or version not set!")
# TODO throw error
return
if version_id is not None:
self.set_version_by_num(version_id)
else:
logger.info("set version to %s", self.version)
self.set_version_by_date(date_issued)
logger.info("set version to %s", self.version)
return
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from dipper.models.Model import Model [as 别名]
# 或者: from dipper.models.Model.Model import addType [as 别名]
#.........这里部分代码省略.........
def __init__(self, graph, ref_id=None, ref_type=None):
if isinstance(graph, Graph):
self.graph = graph
else:
raise ValueError("{} is not a graph".graph)
self.ref_id = ref_id
self.ref_url = None
self.title = None
self.year = None
self.author_list = None
self.short_citation = None
self.model = Model(self.graph)
if ref_type is None:
self.ref_type = self.ref_types['document']
else:
self.ref_type = ref_type
if ref_id is not None and re.match(r'http', ref_id):
self.ref_url = ref_id
return
def setTitle(self, title):
self.title = title
return
def setYear(self, year):
self.year = year
return
def setType(self, reference_type):
self.ref_type = reference_type
return
def setAuthorList(self, author_list):
"""
:param author_list: Array of authors
:return:
"""
self.author_list = author_list
return
def addAuthor(self, author):
self.author_list += [author]
return
def setShortCitation(self, citation):
self.short_citation = citation
return
def addPage(self, subject_id, page_url):
self.graph.addTriple(
subject_id, self.annotation_properties['page'],
page_url, object_is_literal=True)
return
def addTitle(self, subject_id, title):
self.graph.addTriple(
subject_id, self.annotation_properties['title'],
title, object_is_literal=True)
return
def addRefToGraph(self):
n = self.short_citation
if n is None:
n = self.title
if self.ref_url is not None:
self.addTitle(self.ref_url, self.title)
self.model.addType(self.ref_url, self.ref_type)
self.model.addLabel(self.ref_url, n)
elif self.ref_id is not None:
self.model.addIndividualToGraph(self.ref_id, n, self.ref_type)
if self.title is not None:
self.addTitle(self.ref_id, self.title)
else:
# should never be true
logger.error("You are missing an identifier for a reference.")
# TODO what is the property here to add the date?
# if self.year is not None:
# gu.addTriple()
# if self.author_list is not None:
# for a in self.author_list:
# gu.addTriple(
# g, self.ref_id, self.props['has_author'], a, True)
return