def __init__(self, adaptor, primary_id): """Create a DBSeqRecord object. Arguments: - adaptor - A BioSQL.BioSeqDatabase.Adaptor object - primary_id - An internal integer ID used by BioSQL You wouldn't normally create a DBSeqRecord object yourself, this is done for you when using a BioSeqDatabase object """ self._adaptor = adaptor self._primary_id = primary_id (self._biodatabase_id, self._taxon_id, self.name, accession, version, self._identifier, self._division, self.description) = self._adaptor.execute_one( "SELECT biodatabase_id, taxon_id, name, accession, version," " identifier, division, description" " FROM bioentry" " WHERE bioentry_id = %s", (self._primary_id,)) if version and version != "0": self.id = "%s.%s" % (accession, version) else: self.id = accession # We don't yet record any per-letter-annotations in the # BioSQL database, but we should set this property up # for completeness (and the __str__ method). # We do NOT want to load the sequence from the DB here! length = _retrieve_seq_len(adaptor, primary_id) self._per_letter_annotations = _RestrictedDict(length=length)
def _get_per_column_annotations(self): if self._per_col_annotations is None: # This happens if empty at initialisation if len(self): # Use the standard method to get the length expected_length = self.get_alignment_length() else: # Should this raise an exception? Compare SeqRecord behaviour... expected_length = 0 self._per_col_annotations = _RestrictedDict(length=expected_length) return self._per_col_annotations
def _set_per_column_annotations(self, value): if not isinstance(value, dict): raise TypeError("The per-column-annotations should be a " "(restricted) dictionary.") # Turn this into a restricted-dictionary (and check the entries) if len(self): # Use the standard method to get the length expected_length = self.get_alignment_length() self._per_col_annotations = _RestrictedDict(length=expected_length) self._per_col_annotations.update(value) else: # Bit of a problem case... number of columns is undefined self._per_col_annotations = None if value: raise ValueError("Can't set per-column-annotations without an alignment")
def __init__(self, adaptor, primary_id): self._adaptor = adaptor self._primary_id = primary_id (self._biodatabase_id, self._taxon_id, self.name, accession, version, self._identifier, self._division, self.description) = self._adaptor.execute_one( "SELECT biodatabase_id, taxon_id, name, accession, version," " identifier, division, description" " FROM bioentry" " WHERE bioentry_id = %s", (self._primary_id, )) if version and version != "0": self.id = "%s.%s" % (accession, version) else: self.id = accession # We don't yet record any per-letter-annotations in the # BioSQL database, but we should set this property up # for completeness (and the __str__ method). # We do NOT want to load the sequence from the DB here! length = _retrieve_seq_len(adaptor, primary_id) self._per_letter_annotations = _RestrictedDict(length=length)
def __init__(self, adaptor, primary_id): self._adaptor = adaptor self._primary_id = primary_id (self._biodatabase_id, self._taxon_id, self.name, accession, version, self._identifier, self._division, self.description) = self._adaptor.execute_one( "SELECT biodatabase_id, taxon_id, name, accession, version," " identifier, division, description" " FROM bioentry" " WHERE bioentry_id = %s", (self._primary_id,)) if version and version != "0": self.id = "%s.%s" % (accession, version) else: self.id = accession # We don't yet record any per-letter-annotations in the # BioSQL database, but we should set this property up # for completeness (and the __str__ method). # We do NOT want to load the sequence from the DB here! length = _retrieve_seq_len(adaptor, primary_id) self._per_letter_annotations = _RestrictedDict(length=length)
def __init__(self, adaptor, primary_id): self._adaptor = adaptor self._primary_id = primary_id (self._biodatabase_id, self._taxon_id, self.name, accession, version, self._identifier, self._division, self.description) = self._adaptor.execute_one( "SELECT biodatabase_id, taxon_id, name, accession, version," \ " identifier, division, description" \ " FROM bioentry" \ " WHERE bioentry_id = %s", (self._primary_id,)) if version and version != "0": self.id = "%s.%s" % (accession, version) else: self.id = accession #We don't yet record any per-letter-annotations in the #BioSQL database, but we should set this property up #for completeness (and the __str__ method). try : length = len(self.seq) except : #Could be no sequence in the database! length = 0 self._per_letter_annotations = _RestrictedDict(length=length)
def __init__(self, adaptor, primary_id): self._adaptor = adaptor self._primary_id = primary_id (self._biodatabase_id, self._taxon_id, self.name, accession, version, self._identifier, self._division, self.description) = self._adaptor.execute_one( "SELECT biodatabase_id, taxon_id, name, accession, version," \ " identifier, division, description" \ " FROM bioentry" \ " WHERE bioentry_id = %s", (self._primary_id,)) if version and version != "0": self.id = "%s.%s" % (accession, version) else: self.id = accession #We don't yet record any per-letter-annotations in the #BioSQL database, but we should set this property up #for completeness (and the __str__ method). try: length = len(self.seq) except: #Could be no sequence in the database! length = 0 self._per_letter_annotations = _RestrictedDict(length=length)