Returns the GA4GH protocol representation of this ReferenceSet.
556405
def toProtocolElement(self):
        
        ret = protocol.ReferenceSet()
        ret.assembly_id = pb.string(self.getAssemblyId())
        ret.description = pb.string(self.getDescription())
        ret.id = self.getId()
        ret.is_derived = self.getIsDerived()
        ret.md5checksum = self.getMd5Checksum()
        if self.getSpecies():
            term = protocol.fromJson(
                json.dumps(self.getSpecies()), protocol.OntologyTerm)
            ret.species.term_id = term.term_id
            ret.species.term = term.term
        ret.source_accessions.extend(self.getSourceAccessions())
        ret.source_uri = pb.string(self.getSourceUri())
        ret.name = self.getLocalId()
        self.serializeAttributes(ret)
        return ret
638772
public java.lang.String getProtocol() {
    java.lang.Object ref = protocol_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      protocol_ = s;
      return s;
    }
  }
294723
public com.google.protobuf.ByteString
      getRefererBytes() {
    java.lang.Object ref = referer_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      referer_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
156226
def get_goa_gene_sets(go_annotations):
    
    go_term_genes = OrderedDict()
    term_ids = {}
    for ann in go_annotations:
        term_ids[ann.go_term.id] = ann.go_term
        try:
            go_term_genes[ann.go_term.id].append(ann.db_symbol)
        except KeyError:
            go_term_genes[ann.go_term.id] = [ann.db_symbol]
    
    go_term_genes = OrderedDict(sorted(go_term_genes.items()))
    gene_sets = []
    for tid, genes in go_term_genes.items():
        go_term = term_ids[tid]
        gs = GeneSet(id=tid, name=go_term.name, genes=genes,
                     source='GO',
                     collection=go_term.domain_short,
                     description=go_term.definition)
        gene_sets.append(gs)
    gene_sets = GeneSetCollection(gene_sets)
    return gene_sets
1297625
def toProtocolElement(self):
        
        readGroupSet = protocol.ReadGroupSet()
        readGroupSet.id = self.getId()
        readGroupSet.read_groups.extend(
            [readGroup.toProtocolElement()
             for readGroup in self.getReadGroups()]
        )
        readGroupSet.name = self.getLocalId()
        readGroupSet.dataset_id = self.getParentContainer().getId()
        readGroupSet.stats.CopyFrom(self.getStats())
        self.serializeAttributes(readGroupSet)
        return readGroupSet
1060644
def protocol_parameter(self):
        
        for parameter in self.protocol_agent.parameters:
            if parameter.href in self.protocol_agent_values.get('parameter_ref', []):
                return parameter
640711
def nvgre(version=0, vsid=0, flow_id=0):
    

    # NVGRE header
    #  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    # |0| |1|0|   Reserved0     | Ver |   Protocol Type 0x6558        |
    # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    # |               Virtual Subnet ID (VSID)        |    FlowID     |
    # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    return gre(version=version, protocol=ether_types.ETH_TYPE_TEB,
               vsid=vsid, flow_id=flow_id)
512904
def toProtocolElement(self):
        
        # TODO this is very incomplete, but we don't have the
        # implementation to fill out the rest of the fields currently
        readGroup = protocol.ReadGroup()
        readGroup.id = self.getId()
        readGroup.created = self._creationTime
        readGroup.updated = self._updateTime
        dataset = self.getParentContainer().getParentContainer()
        readGroup.dataset_id = dataset.getId()
        readGroup.name = self.getLocalId()
        readGroup.predicted_insert_size = pb.int(self.getPredictedInsertSize())
        referenceSet = self._parentContainer.getReferenceSet()
        readGroup.sample_name = pb.string(self.getSampleName())
        readGroup.biosample_id = pb.string(self.getBiosampleId())
        if referenceSet is not None:
            readGroup.reference_set_id = referenceSet.getId()
        readGroup.stats.CopyFrom(self.getStats())
        readGroup.programs.extend(self.getPrograms())
        readGroup.description = pb.string(self.getDescription())
        readGroup.experiment.CopyFrom(self.getExperiment())
        self.serializeAttributes(readGroup)
        return readGroup
918028
def get_protocols(self, device):
        """"""
        return self._reg.device_builder(device, self._rv).protocols
558387
def get_ga_client_id(self):
        
        request = self.get_ga_request()
        if not request or not hasattr(request, 'session'):
            return super(GARequestErrorReportingMixin, self).get_ga_client_id()
        if 'ga_client_id' not in request.session:
            client_id = self.ga_cookie_re.match(request.COOKIES.get('_ga', ''))
            client_id = client_id and client_id.group('cid') or str(uuid.uuid4())
            request.session['ga_client_id'] = client_id
        return request.session['ga_client_id']
603049
private Map<String, Reference> getReferences(ReadGroupSet readGroupSet) 
      throws IOException, GeneralSecurityException {
    Set<String> referenceSetIds = Sets.newHashSet();
    if (!Strings.isNullOrEmpty(readGroupSet.getReferenceSetId())) {
      LOG.info("Found reference set from read group set " + 
          readGroupSet.getReferenceSetId());
      referenceSetIds.add(readGroupSet.getReferenceSetId());
    }
    if (readGroupSet.getReadGroupsCount() > 0) {
      LOG.info("Found read groups");
      for (ReadGroup readGroup : readGroupSet.getReadGroupsList()) {
        if (!Strings.isNullOrEmpty(readGroup.getReferenceSetId())) {
          LOG.info("Found reference set from read group: " + 
              readGroup.getReferenceSetId());
          referenceSetIds.add(readGroup.getReferenceSetId());
        }
      }
    }
    
    ReferenceServiceV1BlockingStub referenceSetStub = 
        ReferenceServiceV1Grpc.newBlockingStub(getChannel());
        
    Map<String, Reference> references = Maps.newHashMap();
    for (String referenceSetId : referenceSetIds) {
      LOG.info("Getting reference set " + referenceSetId);
      GetReferenceSetRequest getReferenceSetRequest = GetReferenceSetRequest
          .newBuilder().setReferenceSetId(referenceSetId).build();
      ReferenceSet referenceSet = 
          referenceSetStub.getReferenceSet(getReferenceSetRequest);
      if (referenceSet == null || referenceSet.getReferenceIdsCount() == 0) {
        continue;
      }
      for (String referenceId : referenceSet.getReferenceIdsList()) {
        LOG.fine("Getting reference  " + referenceId);
        GetReferenceRequest getReferenceRequest = GetReferenceRequest
            .newBuilder().setReferenceId(referenceId).build();
        Reference reference = referenceSetStub.getReference(getReferenceRequest);
        if (!Strings.isNullOrEmpty(reference.getName())) {
          references.put(reference.getName(), reference);
          LOG.fine("Adding reference  " + reference.getName());
        }
      }
    }
    return references;
  }
494180
def get_transcript_source_set(gtf):
    
    gene_to_source = get_gene_source_set(gtf)
    transcript_to_source = {}
    db = get_gtf_db(gtf)
    for feature in complete_features(db):
        gene_id = feature['gene_id'][0]
        transcript_to_source[feature['transcript_id'][0]] = gene_to_source[gene_id]
    return transcript_to_source
448978
def n_to_g(self, n_interval):
        """"""

        frs, fre = n_interval.start.base - 1, n_interval.end.base - 1
        start_offset, end_offset = n_interval.start.offset, n_interval.end.offset

        if self.strand == -1:
            fre, frs = self.tgt_len - frs - 1, self.tgt_len - fre - 1
            start_offset, end_offset = -end_offset, -start_offset

        # returns the genomic range start (grs) and end (gre)
        grs, _, grs_cigar = self._map(
            from_pos=self.tgt_pos, to_pos=self.ref_pos, pos=frs, base="start")
        gre, _, gre_cigar = self._map(
            from_pos=self.tgt_pos, to_pos=self.ref_pos, pos=fre, base="end")
        grs, gre = grs + self.gc_offset + 1, gre + self.gc_offset + 1
        gs, ge = grs + start_offset, gre + end_offset

        # The returned interval would be uncertain when locating at alignment gaps
        return hgvs.location.Interval(
            start=hgvs.location.SimplePosition(gs, uncertain=n_interval.start.uncertain),
            end=hgvs.location.SimplePosition(ge, uncertain=n_interval.end.uncertain),
            uncertain=grs_cigar in 'DI' or gre_cigar in 'DI')
42609
public String toGav() {
        if (purl.getNamespace() != null && purl.getVersion() != null) {
            return String.format("%s:%s:%s", purl.getNamespace(), purl.getName(), purl.getVersion());
        }
        return null;
    }
485188
public static String getEOReferenceStringFromAnnotation(OpenEngSBForeignKey key) {
        return String.format("%s%s:%s", REFERENCE_PREFIX, key.modelType(), key.modelVersion().toString());
    }
638662
def getVariantAnnotationId(self, gaVariant, gaAnnotation):
        
        md5 = self.hashVariantAnnotation(gaVariant, gaAnnotation)
        compoundId = datamodel.VariantAnnotationCompoundId(
            self.getCompoundId(), gaVariant.reference_name,
            str(gaVariant.start), md5)
        return str(compoundId)
148401
def dbg_repr(self):
        

        stack = [ ]
        for i, frame in enumerate(self):
            s = "%d | %s -> %s, returning to %s" % (
                i,
                "None" if frame.call_site_addr is None else "%#x" % frame.call_site_addr,
                "None" if frame.func_addr is None else "%#x" % frame.func_addr,
                "None" if frame.return_target is None else "%#x" % frame.return_target,
            )
            stack.append(s)

        return "\n".join(stack)