コード例 #1
0
ファイル: proxy.py プロジェクト: DirkHaehnel/omero.biobank
 def create_snp_markers_set(self, label, maker, model, release,
                            N, stream, action):
   """
   Given a stream of (marker_vid, marker_indx, allele_flip) tuples,
   build and save a new marker set.
   """
   assert type(N) == int and N > 0
   set_vid = vlu.make_vid()
   conf = {
     'label': label,
     'maker': maker,
     'model': model,
     'release': release,
     'markersSetVID': set_vid,
     'action': action,
     }
   mset = self.factory.create(self.SNPMarkersSet, conf)
   mset.save()
   def gen(stream):
     for t in stream:
       yield {'marker_vid': t[0], 'marker_indx': t[1], 'allele_flip': t[2]}
   # TODO: add better exception handling to the following code
   try:
     self.gadpt.create_snp_markers_set_tables(mset.id, N)
     counted = self.gadpt.define_snp_markers_set(set_vid, gen(stream),
                                                 action.id)
     if counted != N:
       raise ValueError('there are %d records in stream (expected %d)' %
                        (counted, N))
   except:
     self.gadpt.delete_snp_markers_set_tables(mset.id)
     self.delete(mset)
     raise
   return mset
コード例 #2
0
 def configurator(self, ome_obj, conf):
   base.__config__(self, ome_obj, conf)
   conf = self.__preprocess_conf__(conf)
   for k, t in fields.iteritems():
     if k is 'vid':
       setattr(ome_obj, k, self.to_omero(STRING, vlu.make_vid()))
     elif k in conf:
       setattr(ome_obj, k, self.to_omero(t[0], conf[k]))
     elif t[1] is REQUIRED:
       raise ValueError('missing value for required field %s' % k)
コード例 #3
0
ファイル: wrapper.py プロジェクト: jburel/omero.biobank
 def configurator(self, ome_obj, conf):
     base.__config__(self, ome_obj, conf)
     conf = self.__preprocess_conf__(conf)
     for k, t in fields.iteritems():
         if k is "vid":
             setattr(ome_obj, k, self.to_omero(STRING, vlu.make_vid()))
         elif k in conf:
             setattr(ome_obj, k, self.to_omero(t[0], conf[k]))
         elif t[1] is REQUIRED:
             raise ValueError("missing value for required field %s" % k)
コード例 #4
0
ファイル: proxy.py プロジェクト: flywind2/omero.biobank
    def add_ehr_record(self, action, timestamp, archetype, rec):
        """
    multi-field records will be expanded to groups of records all
    with the same (assumed to be unique within a KB) group id.

    :param action: action that generated this record
    :type action: ActionOnIndividual

    :param timestamp: when this record was collected, in millisecond
      since the Epoch
    :type timestamp: long

    :param archetype: a legal archetype id, e.g.,
      ``openEHR-EHR-EVALUATION.problem-diagnosis.v1``
    :type archetype:  str

    :param rec: keys and values for this specific archetype instance,
      e.g., ``{'at0002.1':
      'terminology://apps.who.int/classifications/apps/gE10.htm#E10'}``

    :type rec: dict
    """
        self.__check_type('action', self.ActionOnIndividual, action)
        self.__check_type('rec', dict, rec)
        action.reload()
        a_id = action.id
        target = action.target
        target.reload()
        i_id = target.id
        # TODO add archetype consistency checks
        g_id = vlu.make_vid()
        for k in rec:
            row = {
                'timestamp': timestamp,
                'i_vid': i_id,
                'a_vid': a_id,
                'valid': True,
                'g_vid': g_id,
                'archetype': archetype,
                'field': k,
                'value': rec[k],
            }
            self.eadpt.add_eav_record_row(row)
コード例 #5
0
ファイル: proxy.py プロジェクト: DirkHaehnel/omero.biobank
  def add_ehr_record(self, action, timestamp, archetype, rec):
    """
    multi-field records will be expanded to groups of records all
    with the same (assumed to be unique within a KB) group id.

    :param action: action that generated this record
    :type action: ActionOnIndividual

    :param timestamp: when this record was collected, in millisecond
      since the Epoch
    :type timestamp: long

    :param archetype: a legal archetype id, e.g.,
      ``openEHR-EHR-EVALUATION.problem-diagnosis.v1``
    :type archetype:  str

    :param rec: keys and values for this specific archetype instance,
      e.g., ``{'at0002.1':
      'terminology://apps.who.int/classifications/apps/gE10.htm#E10'}``

    :type rec: dict
    """
    self.__check_type('action', self.ActionOnIndividual, action)
    self.__check_type('rec', dict, rec)
    action.reload()
    a_id = action.id
    target = action.target
    target.reload()
    i_id = target.id
    # TODO add archetype consistency checks
    g_id = vlu.make_vid()
    for k in rec:
      row = {
        'timestamp': timestamp,
        'i_vid': i_id,
        'a_vid': a_id,
        'valid': True,
        'g_vid': g_id,
        'archetype': archetype,
        'field': k,
        'value': rec[k],
        }
      self.eadpt.add_eav_record_row(row)
コード例 #6
0
ファイル: proxy.py プロジェクト: flywind2/omero.biobank
    def create_snp_markers_set(self, label, maker, model, release, N, stream,
                               action):
        """
    Given a stream of (marker_vid, marker_indx, allele_flip) tuples,
    build and save a new marker set.
    """
        assert type(N) == int and N > 0
        set_vid = vlu.make_vid()
        conf = {
            'label': label,
            'maker': maker,
            'model': model,
            'release': release,
            'markersSetVID': set_vid,
            'action': action,
        }
        mset = self.factory.create(self.SNPMarkersSet, conf)
        mset.save()

        def gen(stream):
            for t in stream:
                yield {
                    'marker_vid': t[0],
                    'marker_indx': t[1],
                    'allele_flip': t[2]
                }

        # TODO: add better exception handling to the following code
        try:
            self.gadpt.create_snp_markers_set_tables(mset.id, N)
            counted = self.gadpt.define_snp_markers_set(
                set_vid, gen(stream), action.id)
            if counted != N:
                raise ValueError(
                    'there are %d records in stream (expected %d)' %
                    (counted, N))
        except:
            self.gadpt.delete_snp_markers_set_tables(mset.id)
            self.delete(mset)
            raise
        return mset
コード例 #7
0
ファイル: utils.py プロジェクト: DirkHaehnel/omero.biobank
def assign_vid(conf):
  conf.setdefault('vid', vu.make_vid())
  return conf
コード例 #8
0
def assign_vid(conf):
    conf.setdefault('vid', vu.make_vid())
    return conf