Пример #1
0
 def __call__(self, length):
     "Retrieve a random sequence."
     while True:
         id, start, stop, orientation = self._choose_entry_point()
         max_pos = stop-1-length
         if max_pos > start:
             pos = R.randint(start, max_pos)
             segment = das.encode_segment(id, pos, pos+length)
             id, start, stop, version, seq = das.fetch_dna(self.prefix, segment)
             if seq.count('n') < length / 4: # make sure does not have too many 'N's
                 return seq
Пример #2
0
 def __call__(self, length):
     "Retrieve a random sequence."
     while True:
         id, start, stop, orientation = self._choose_entry_point()
         max_pos = stop - 1 - length
         if max_pos > start:
             pos = R.randint(start, max_pos)
             segment = das.encode_segment(id, pos, pos + length)
             id, start, stop, version, seq = das.fetch_dna(
                 self.prefix, segment)
             if seq.count(
                     'n'
             ) < length / 4:  # make sure does not have too many 'N's
                 return seq
Пример #3
0
def get_dna_for_region(url, label, id_, start, end, padding_bases):
    "@return: A Bio.Seq.SeqRecord for the specified region."
    segment = '%s:%d,%d' % (id_, start-padding_bases, end+padding_bases)
    _, _, _, _, sequence = das.fetch_dna(url, segment)
    logging.debug('%s: DNA from %s for segment %s: %s' % (label, url, segment, sequence))
    return SeqRecord(Seq(sequence, DNAAlphabet()), id=label, description='%s %s' % (url, segment))