Пример #1
0
 def __init__(self, seq, fwd_coded_seq=None, rc_coded_seq=None, include_shape=False):
     self.seq = seq
     
     if fwd_coded_seq is None:
         fwd_one_hot_coded_seq = one_hot_encode_sequence(seq)
         if include_shape:
             fwd_coded_shape = code_sequence_shape(seq)
             fwd_coded_seq = np.hstack((fwd_one_hot_coded_seq, fwd_coded_shape))
         else:
             fwd_coded_seq = fwd_one_hot_coded_seq
     if rc_coded_seq is None:
         rc_seq = reverse_complement(seq)
         rc_one_hot_coded_seq = one_hot_encode_sequence(rc_seq)
         if include_shape:
             rc_coded_shape = code_sequence_shape(rc_seq)
             rc_coded_seq = np.hstack((rc_one_hot_coded_seq, rc_coded_shape))
         else:
             rc_coded_seq = rc_one_hot_coded_seq
     
     self.fwd_coded_seq = fwd_coded_seq
     self.rc_coded_seq = rc_coded_seq
Пример #2
0
 def score_binding_sites(self, seq, direction):
     """Score all binding sites in seq.
     
     """
     assert direction in ScoreDirection.__slots__
     if isinstance(seq, str):
         coded_seq = one_hot_encode_sequence(seq)
     elif isinstance(seq, DNASequence):
         coded_seq = seq.one_hot_coded_seq
     elif isinstance(seq, OneHotCodedDNASeq):
         coded_seq = seq
     else:
         assert False, "Unrecognized sequence type '%s'" % str(type(seq))
     return score_coded_seq_with_convolutional_filter(
         coded_seq, self.convolutional_filter, direction=direction)
Пример #3
0
    def __init__(self, seq, one_hot_coded_seq=None):
        self.seq = seq

        if one_hot_coded_seq is None:
            one_hot_coded_seq = one_hot_encode_sequence(seq)
        self.one_hot_coded_seq = one_hot_coded_seq