Ejemplo n.º 1
0
    def pull_as_onehot(self, batch_size):
        #Calls the pull function to retrieve a list of nucleotide sequences
        #Converts the nucleotides to a [batch_size,4,seq_len] onehot numpy array
        nuc_list = self.pull(batch_size)

        dna_batch = np.zeros((batch_size, 4, self.seq_len))
        #labels_batch = np.ones((batch_size))*label
        for bi, seq in enumerate(nuc_list):
            dna_batch[bi, :, :] = dbt.seq_to_onehot(seq)
        return dna_batch
Ejemplo n.º 2
0
    def relevance_from_nucs(self, nucs, label):
        """
        Return the relevance of a nucleotide sequence and corresponding label
                
        :nuc_seq: string nucleotide sequence
        :label: 1 x num_classes numpy indicator array
        :returns: 4xn relevance matrix
        :rtype: numpy array
        """

        return self.run_relevance(dbt.seq_to_onehot(nuc_seq), label)
Ejemplo n.º 3
0
def main():
    nucs = ['ATACGACGACT','GTACGACGTAC','GTCGATGCATG']
    nuc_3d = np.zeros(  ( len(nucs),len(nucs[0]),4 )   )
    for i,nuc in enumerate(nucs):
        nuc_3d[i,:,:] = dbt.seq_to_onehot_topdown(nuc)

    nuc_3d_ten = tf.stack(nuc_3d)

    #test_reverse_sequence(nuc_3d)

    print "Test complement"
    #test_com(nuc_3d_ten)

    print "Test reverse complement"
    #test_revcom(nuc_3d_ten)

    #test_nuc_input(nuc_3d_ten)


    print "Test seq to onehot"
    print dbt.seq_to_onehot('AACGTCG').T
Ejemplo n.º 4
0
 def pull_index_onehot(self, index):
     numeric_label = self.label_from_index(index)
     iseq = self.seq_parser_list[index].seq
     nuc_onehot = dbt.seq_to_onehot(iseq)  #(outputs nx4)
     return numeric_label, nuc_onehot
Ejemplo n.º 5
0
 def pull_index_onehot(self, index):
     return self.labels[index], dbt.seq_to_onehot(self.nuc_seqs[index])