# build CNN model model = Sequential() model.add(Conv2D(50, kernel_size=(20, 12), activation='relu')) model.add(MaxPooling2D(pool_size=(1, 2))) model.add(Flatten()) model.add(Dropout(0.3)) model.add(Dense(650, activation='relu')) model.add(Dropout(0.3)) model.add(Dense(2, activation='softmax')) model.compile(loss=keras.losses.categorical_crossentropy, optimizer=keras.optimizers.Adadelta(lr=0.01), metrics=['accuracy']) print('Loading training data...') pos_Train = readFile("./data/pos_training_dataset.txt", maxlen) neg_Train = readFile("./data/neg_training_dataset_2.txt", maxlen) print('Generating labels and features...') (y_train, x_train) = createTrainTestData(pos_Train, neg_Train, "Onehot") print('Shuffling the data...') index = np.arange(len(y_train)) np.random.shuffle(index) x_train = x_train[index, :] y_train = y_train[index] x_train = x_train.reshape(x_train.shape[0], seq_rows, seq_cols, 1) y_train = keras.utils.to_categorical(y_train, num_classes) print('Training...')
DeepT3_1 = model_from_json(json_string) DeepT3_1.load_weights( os.path.join(args.DeepT3_directory, 'models_weights/DeepT3_1.h5')) with open( os.path.join(args.DeepT3_directory, 'models_weights/DeepT3_2.json'), 'r') as f: json_string = f.read() DeepT3_2 = model_from_json(json_string) DeepT3_2.load_weights( os.path.join(args.DeepT3_directory, 'models_weights/DeepT3_2.h5')) print('Loading data...') testData = readFile(args.fasta_file, maxlen) print('Generating features...') x_test = createData(testData, "Onehot") x_test = x_test.reshape(x_test.shape[0], seq_rows, seq_cols, 1) print('Predicting...') predicted_Probability_1 = DeepT3_1.predict(x_test) predicted_Probability_2 = DeepT3_2.predict(x_test) prediction_1 = DeepT3_1.predict_classes(x_test) prediction_2 = DeepT3_2.predict_classes(x_test) prediction = prediction_1 + prediction_2 faa_accessions = [i.name for i in SeqIO.parse(args.fasta_file, "fasta")] print('Saving the result..')
# build CNN model model = Sequential() model.add(Conv2D(50, kernel_size=(20,14),activation='relu')) model.add(MaxPooling2D(pool_size=(1,2))) model.add(Flatten()) model.add(Dropout(0.3)) model.add(Dense(650, activation='relu')) model.add(Dropout(0.3)) model.add(Dense(2, activation='softmax')) model.compile(loss=keras.losses.categorical_crossentropy,optimizer=keras.optimizers.Adadelta(lr=0.006),metrics=['accuracy']) print('Loading training data...') pos_Train = readFile("./data/pos_train.txt",maxlen) neg_Train = readFile("./data/neg_train.txt",maxlen) print('Generating labels and features...') (y_train, x_train) = createTrainTestData(pos_Train,neg_Train,"Onehot") print('Shuffling the data...') index = np.arange(len(y_train)) np.random.shuffle(index) x_train = x_train[index,:] y_train = y_train[index] x_train = x_train.reshape(x_train.shape[0],seq_rows, seq_cols,1) y_train = keras.utils.to_categorical(y_train, num_classes) print('Training...')
print('Loading model...') with open('./models_weights/DeepT3_1.json', 'r') as f: json_string = f.read() DeepT3_1 = model_from_json(json_string) DeepT3_1.load_weights('./models_weights/DeepT3_1.h5') with open('./models_weights/DeepT3_2.json', 'r') as f: json_string = f.read() DeepT3_2 = model_from_json(json_string) DeepT3_2.load_weights('./models_weights/DeepT3_2.h5') print('Loading data...') testData = readFile("./data/t4sptrain263.txt", maxlen) print('Generating features...') x_test = createData(testData, "Onehot") x_test = x_test.reshape(x_test.shape[0], seq_rows, seq_cols, 1) print('Predicting...') predicted_Probability_1 = DeepT3_1.predict(x_test) predicted_Probability_2 = DeepT3_2.predict(x_test) prediction_1 = DeepT3_1.predict_classes(x_test) prediction_2 = DeepT3_2.predict_classes(x_test) prediction = prediction_1 + prediction_2 print('Saving the result..') f = open("result.txt", "w") for i in prediction:
import numpy as np maxlen = 150 seq_rows, seq_cols = 20, maxlen print('Loading model...') with open('./models_weights/json_model.json', 'r') as f: json_string = f.read() model = model_from_json(json_string) model.load_weights('./models_weights/model_weights.h5') print('Loading data...') testData = readFile("./data/S.cerevisiae-RBP354.txt", maxlen) print('Generating features...') x_test = createData(testData, "Onehot") x_test = x_test.reshape(x_test.shape[0], seq_rows, seq_cols, 1) print('Predicting...') predicted_Probability = model.predict(x_test) prediction = model.predict_classes(x_test) print('Saving the result..') f = open("result.txt", "w") for i in prediction: if i == 1: f.write("T4SE\n")