Loading moldyn_example/scripts/conv_vae.py +10 −7 Original line number Diff line number Diff line Loading @@ -84,7 +84,8 @@ class conv_variational_autoencoder(object): #even shaped filters may cause problems in theano backend even_filters = [f for pair in filter_shapes for f in pair if f % 2 == 0] if K.image_dim_ordering() == 'th' and len(even_filters) > 0: if (K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first') \ and len(even_filters) > 0: warnings.warn('Even shaped filters may cause problems in Theano backend') self.eps_mean = eps_mean Loading @@ -92,7 +93,7 @@ class conv_variational_autoencoder(object): self.image_size = image_size #define input layer if K.image_dim_ordering() == 'th': if K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first': self.input = Input(shape=(channels,image_size[0],image_size[1])) else: self.input = Input(shape=(image_size[0],image_size[1],channels)) Loading Loading @@ -140,7 +141,7 @@ class conv_variational_autoencoder(object): #dummy model to get image size after encoding convolutions self.decode_conv = [] if K.image_dim_ordering() == 'th': if K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first': dummy_input = np.ones((1,channels,image_size[0],image_size[1])) else: dummy_input = np.ones((1,image_size[0],image_size[1],channels)) Loading @@ -155,14 +156,14 @@ class conv_variational_autoencoder(object): #define deconvolutional decoding layers for i in range(1,conv_layers): if K.image_dim_ordering() == 'th': if K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first': dummy_input = np.ones((1,channels,image_size[0],image_size[1])) else: dummy_input = np.ones((1,image_size[0],image_size[1],channels)) dummy = Model(self.input, self.encode_conv[-i-1]) conv_size = list(dummy.predict(dummy_input).shape) if K.image_dim_ordering() == 'th': if K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first': conv_size[1] = feature_maps[-i] else: conv_size[3] = feature_maps[-i] Loading Loading @@ -322,6 +323,8 @@ if __name__ == "__main__": import sys import os import gzip from six.moves import cPickle import matplotlib.pyplot as plt from scipy.stats import norm Loading @@ -334,9 +337,9 @@ if __name__ == "__main__": channels = 1 batch_size = 1000 conv_layers = 4 feature_maps = [256,256,256,256] feature_maps = [64,64,64,64] filter_shapes = [(1,3),(1,3),(3,3),(3,3)] strides = [(1,1),(1,3),(1,1),(1,1)] strides = [(1,1),(2,2),(1,1),(1,1)] dense_layers = 1 dense_neurons = [128] dense_dropouts = [0] Loading moldyn_example/scripts/dcd2array.py +4 −4 Original line number Diff line number Diff line Loading @@ -9,8 +9,8 @@ import shutil # get directory to dcd files args = (sys.argv) if len(args) != 2: raise Exception("Usage: python feature_extraction.py <path to dcd files>") if len(args) != 3: raise Exception("Usage: python feature_extraction.py <path to dcd files> <residue_start:residue_end>") dcd_path = args[1] if dcd_path[-1] != '/': dcd_path += '/' Loading @@ -23,7 +23,7 @@ if not os.path.exists('./results'): files = glob.glob(dcd_path+'*-protein-*.dcd') n = len(files) dataset_name = os.path.basename(files[0]).split('-protein-')[0] file_basename = os.path.basename(files[0])[:-7] file_basename = os.path.basename(files[0])[:-8] # process dcd files k = 0 Loading @@ -37,7 +37,7 @@ for i in range(n): from MDAnalysis.analysis import contacts # crude definition of salt bridges as contacts between CA atoms CA = "(name CA and resid 1:21)" CA = "(name CA and resid %s)" % args[2] # reference groups (first frame of the trajectory, but you could also use a # separate PDB, eg crystal structure) CA0 = u0.select_atoms(CA) Loading Loading
moldyn_example/scripts/conv_vae.py +10 −7 Original line number Diff line number Diff line Loading @@ -84,7 +84,8 @@ class conv_variational_autoencoder(object): #even shaped filters may cause problems in theano backend even_filters = [f for pair in filter_shapes for f in pair if f % 2 == 0] if K.image_dim_ordering() == 'th' and len(even_filters) > 0: if (K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first') \ and len(even_filters) > 0: warnings.warn('Even shaped filters may cause problems in Theano backend') self.eps_mean = eps_mean Loading @@ -92,7 +93,7 @@ class conv_variational_autoencoder(object): self.image_size = image_size #define input layer if K.image_dim_ordering() == 'th': if K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first': self.input = Input(shape=(channels,image_size[0],image_size[1])) else: self.input = Input(shape=(image_size[0],image_size[1],channels)) Loading Loading @@ -140,7 +141,7 @@ class conv_variational_autoencoder(object): #dummy model to get image size after encoding convolutions self.decode_conv = [] if K.image_dim_ordering() == 'th': if K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first': dummy_input = np.ones((1,channels,image_size[0],image_size[1])) else: dummy_input = np.ones((1,image_size[0],image_size[1],channels)) Loading @@ -155,14 +156,14 @@ class conv_variational_autoencoder(object): #define deconvolutional decoding layers for i in range(1,conv_layers): if K.image_dim_ordering() == 'th': if K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first': dummy_input = np.ones((1,channels,image_size[0],image_size[1])) else: dummy_input = np.ones((1,image_size[0],image_size[1],channels)) dummy = Model(self.input, self.encode_conv[-i-1]) conv_size = list(dummy.predict(dummy_input).shape) if K.image_dim_ordering() == 'th': if K.image_dim_ordering() == 'th' or K.image_dim_ordering() == 'channels_first': conv_size[1] = feature_maps[-i] else: conv_size[3] = feature_maps[-i] Loading Loading @@ -322,6 +323,8 @@ if __name__ == "__main__": import sys import os import gzip from six.moves import cPickle import matplotlib.pyplot as plt from scipy.stats import norm Loading @@ -334,9 +337,9 @@ if __name__ == "__main__": channels = 1 batch_size = 1000 conv_layers = 4 feature_maps = [256,256,256,256] feature_maps = [64,64,64,64] filter_shapes = [(1,3),(1,3),(3,3),(3,3)] strides = [(1,1),(1,3),(1,1),(1,1)] strides = [(1,1),(2,2),(1,1),(1,1)] dense_layers = 1 dense_neurons = [128] dense_dropouts = [0] Loading
moldyn_example/scripts/dcd2array.py +4 −4 Original line number Diff line number Diff line Loading @@ -9,8 +9,8 @@ import shutil # get directory to dcd files args = (sys.argv) if len(args) != 2: raise Exception("Usage: python feature_extraction.py <path to dcd files>") if len(args) != 3: raise Exception("Usage: python feature_extraction.py <path to dcd files> <residue_start:residue_end>") dcd_path = args[1] if dcd_path[-1] != '/': dcd_path += '/' Loading @@ -23,7 +23,7 @@ if not os.path.exists('./results'): files = glob.glob(dcd_path+'*-protein-*.dcd') n = len(files) dataset_name = os.path.basename(files[0]).split('-protein-')[0] file_basename = os.path.basename(files[0])[:-7] file_basename = os.path.basename(files[0])[:-8] # process dcd files k = 0 Loading @@ -37,7 +37,7 @@ for i in range(n): from MDAnalysis.analysis import contacts # crude definition of salt bridges as contacts between CA atoms CA = "(name CA and resid 1:21)" CA = "(name CA and resid %s)" % args[2] # reference groups (first frame of the trajectory, but you could also use a # separate PDB, eg crystal structure) CA0 = u0.select_atoms(CA) Loading