#!/usr/bin/env python # -*- coding: utf-8 -*- # # Model.py # # Copyright 2013 Daniele Raimondi # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. from globalSettings import * import pickle class ModelSettings: def __init__(self, name, action=""): if action == "read": print "Reading settings from %s" % (name) , settings = pickle.load(open(name+".settings", "r")) print "Done." print "Setting parameters...", global nonExistentCont, allTP, percCoverage_train, percCoverage_neighborhood, percCoverage_prediction, lower_train, higher_train, contact_threshold_pred, minSeqDist, path, numProc, parallel, files, numFeatures, windowRadius, layersNum nonExistentCont = settings.nonExistentCont #one experiment (ah-ah) says that -1 is better than 0 ###############: READING FROM SCRATCH allTP =settings.allTP percCoverage_train =settings.percCoverage_train percCoverage_neighborhood =settings.percCoverage_neighborhood percCoverage_prediction =settings.percCoverage_prediction #7.5 - 10.5 seem good for some proteins lower_train =settings.lower_train higher_train =settings.higher_train contact_threshold_pred =settings.contact_threshold_pred #the values above are valid only for the training if lower_train > higher_train: raise Exception("Nonsense here: lower should be lower than higher.") minSeqDist =settings.minSeqDist ###############: LEARNING path =settings.path numProc =settings.numProc parallel =settings.parallel files =settings.files numFeatures = len(files) ###############: DEEP LEARNING windowRadius =settings.windowRadius layersNum =settings.layersNum print "Done." elif action == "set": print "Storing parameters settings..." ###############: GENERAL self.nonExistentCont = nonExistentCont #one experiment (ah-ah) says that -1 is better than 0 ###############: READING FROM SCRATCH self.allTP = allTP #not yet tested with true self.percCoverage_train = percCoverage_train self.percCoverage_neighborhood = percCoverage_neighborhood self.percCoverage_prediction = percCoverage_prediction #7.5 - 10.5 seem good for some proteins self.lower_train = lower_train self.higher_train = higher_train self.contact_threshold_pred = contact_threshold_pred #the values above are valid only for the training if lower_train > higher_train: raise Exception("Nonsense here: lower should be lower than higher.") self.minSeqDist = 6 ###############: LEARNING self.path = path self.numProc = numProc self.parallel = parallel self.files = files self.numFeatures = len(files) ###############: DEEP LEARNING self.windowRadius = windowRadius self.layersNum = layersNum print "Dumping...", pickle.dump(self, open(name+".settings", "w"),2) print "Done." else: raise Exception("Unknown action!") def main(): return 0 if __name__ == '__main__': main()