Infer the antibiotics resistance of the given record.

    Arguments:
        record (`~Bio.SeqRecord.SeqRecord`): an annotated sequence.

    Raises:
        RuntimeError: when there's not exactly one resistance cassette.
3891
def find_resistance(record):
    
    for feature in record.features:
        labels = set(feature.qualifiers.get("label", []))
        cassettes = labels.intersection(_ANTIBIOTICS)
        if len(cassettes) > 1:
            raise RuntimeError("multiple resistance cassettes detected")
        elif len(cassettes) == 1:
            return _ANTIBIOTICS.get(cassettes.pop())
    raise RuntimeError("could not find the resistance of '{}'".format(record.id))
762406
def record(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('PN record not yet initialized!')

        return b'PN' + struct.pack('=BBLLLL', RRPNRecord.length(), SU_ENTRY_VERSION, self.dev_t_high, utils.swab_32bit(self.dev_t_high), self.dev_t_low, utils.swab_32bit(self.dev_t_low))
697014
def record(self, i=0):
        """"""
        f = self.__getFileObj(self.dbf)
        if self.numRecords is None:
            self.__dbfHeader()
        i = self.__restrictIndex(i)
        recSize = self.__recStruct.size
        f.seek(0)
        f.seek(self.__dbfHdrLength + (i * recSize))
        return self.__record(oid=i)
735749
def filter_record(self, record):
        
        nloc = record.seq.find('N')
        if nloc == -1:
            return record
        elif self.action == 'truncate':
            return record[:nloc]
        elif self.action == 'drop':
            raise FailedFilter()
        else:
            assert False
766852
def inferSequence(exp, sequenceId, sequences, objectName=0):
  """"""
  # Create the (loc, feat) pairs for this sequence for column 0.
  objectSensations = {
    0: [pair for pair in sequences[sequenceId]]
  }

  inferConfig = {
    "object": sequenceId,
    "numSteps": len(objectSensations[0]),
    "pairs": objectSensations,
  }

  inferenceSDRs = sequences.provideObjectToInfer(inferConfig)
  exp.infer(inferenceSDRs, objectName=objectName)
517771
def loadRecord(self, domain, rtype, callback=None, errback=None):
        
        rec = Record(self, domain, rtype)
        return rec.load(callback=callback, errback=errback)
696761
def records(self):
        
        first = True
        with as_handle(self._filename) as fp:
            for record in NCBIXML.parse(fp):
                if first:
                    self.params = self._convertBlastParamsToDict(record)
                    first = False
                yield record
213418
def seq_include(records, filter_regex):
    
    regex = re.compile(filter_regex)
    for record in records:
        if regex.search(str(record.seq)):
            yield record
1336742
def to_record(self, sequenced_item):
        
        kwargs = self.get_field_kwargs(sequenced_item)
        # Supply application_name, if needed.
        if hasattr(self.record_class, 'application_name'):
            kwargs['application_name'] = self.application_name
        # Supply pipeline_id, if needed.
        if hasattr(self.record_class, 'pipeline_id'):
            kwargs['pipeline_id'] = self.pipeline_id
        return self.record_class(**kwargs)
1000213
def cdsparse(self, record):
        
        try:
            # Find genes that are present in all strains of interest - the number of times the gene is found is
            # equal to the number of strains. Earlier parsing ensures that the same gene is not present in a strain
            # more than once
            if self.genes[self.genenames[record.id]] == len(self.runmetadata.samples):
                # Add the gene names and sequences to the appropriate dictionaries
                try:
                    self.genesequence[self.genenames[record.id]].add(str(record.seq))
                # Initialise the dictionary as required, then populate as above
                except KeyError:
                    self.genesequence[self.genenames[record.id]] = set()
                    self.genesequence[self.genenames[record.id]].add(str(record.seq))
                try:
                    self.coresequence[str(record.seq)].add(record.id)
                except KeyError:
                    self.coresequence[str(record.seq)] = set()
                    self.coresequence[str(record.seq)].add(record.id)
        except KeyError:
            pass
1361967
def record(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('RR record not yet initialized!')

        return b'RR' + struct.pack('=BBB', RRRRRecord.length(), SU_ENTRY_VERSION, self.rr_flags)
283028
def printBlastRecordForDerek(record):
    
    if len(record.alignments) == 0:
        return 0
    if record.descriptions[0].e > 1e-120:
        return 0
    print(record.query, end=' ')
    for i, alignment in enumerate(record.alignments):
        print(record.descriptions[i].e, end=' ')
        for hspIndex, hsp in enumerate(alignment.hsps, start=1):
            if hsp.sbjct_start < hsp.sbjct_end:
                sense = 1
                if hsp.sbjct_start < 2200:
                    side = 'left'
                else:
                    side = 'right'
            else:
                sense = -1
                if hsp.sbjct_end < 2200:
                    side = 'left'
                else:
                    side = 'right'
            print(sense, side)
            break
    return 1
385593
def filter_record(self, record):
        
        quality_scores = record.letter_annotations['phred_quality']

        mean_score = mean(quality_scores)
        if mean_score >= self.min_mean_score:
            return record
        else:
            raise FailedFilter(mean_score)
337653
def record(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('SP record not yet initialized!')

        return b'SP' + struct.pack('=BBBBB', RRSPRecord.length(), SU_ENTRY_VERSION, 0xbe, 0xef, self.bytes_to_skip)
402977
def setRecord( self, record ):
        
        self._record = record
        
        if ( not record ):
            return
        
        self.setModel(record.__class__)
        schema = self.model().schema()
        
        # set the information
        column_edits = self.findChildren(XOrbColumnEdit)
        for widget in column_edits:
            columnName  = widget.columnName()
            column      = schema.column(columnName)
            
            if ( not column ):
                logger.warning('%s is not a valid column of %s.' % \
                               (columnName, schema.name()))
                continue
                
            # update the values
            widget.setValue(record.recordValue(columnName))
988161
def __try_read_record(self):
    
    block_remaining = _BLOCK_SIZE - self.__reader.tell() % _BLOCK_SIZE
    if block_remaining < _HEADER_LENGTH:
      return ('', _RECORD_TYPE_NONE)

    header = self.__reader.read(_HEADER_LENGTH)
    if len(header) != _HEADER_LENGTH:
      raise EOFError('Read %s bytes instead of %s' %
                     (len(header), _HEADER_LENGTH))

    (masked_crc, length, record_type) = struct.unpack(_HEADER_FORMAT, header)
    crc = _unmask_crc(masked_crc)

    if length + _HEADER_LENGTH > block_remaining:
      # A record can't be bigger than one block.
      raise errors.InvalidRecordError('Length is too big')

    data = self.__reader.read(length)
    if len(data) != length:
      raise EOFError('Not enough data read. Expected: %s but got %s' %
                     (length, len(data)))

    if record_type == _RECORD_TYPE_NONE:
      return ('', record_type)

    actual_crc = crc32c.crc_update(crc32c.CRC_INIT, [record_type])
    actual_crc = crc32c.crc_update(actual_crc, data)
    actual_crc = crc32c.crc_finalize(actual_crc)

    if actual_crc != crc:
      raise errors.InvalidRecordError('Data crc does not match')
    return (data, record_type)
89693
def get_structure_seqs(self, model):
        

        # Don't overwrite existing ChainProp objects
        dont_overwrite = []
        chains = list(model.get_chains())
        for x in chains:
            if self.chains.has_id(x.id):
                if self.chains.get_by_id(x.id).seq_record:
                    dont_overwrite.append(x.id)
        if len(dont_overwrite) == len(chains):
            log.debug('Not writing structure sequences, already stored')
            return

        # Returns the structures sequences with Xs added
        structure_seqs = ssbio.protein.structure.properties.residues.get_structure_seqrecords(model)
        log.debug('{}: gathered chain sequences'.format(self.id))

        # Associate with ChainProps
        for seq_record in structure_seqs:
            log.debug('{}: adding chain sequence to ChainProp'.format(seq_record.id))
            my_chain = self.chains.get_by_id(seq_record.id)
            my_chain.seq_record = seq_record