예제 #1
0
    def run(self, name, datafiles, goldnet_file):
        import numpy

        os.chdir(os.environ["gene_path"])

        datastore = ReadData(datafiles[0], "steadystate")
        for file in datafiles[1:]:
            datastore.combine(ReadData(file, "steadystate"))
        datastore.normalize()

        settings = {}
        settings = ReadConfig(settings)
        # TODO: CHANGE ME
        settings["global"]["working_dir"] = os.getcwd() + '/'

        # Setup job manager
        print "Starting new job manager"
        jobman = JobManager(settings)

        # Make GENIE3 jobs
        genie3 = GENIE3()
        genie3.setup(datastore, settings, name)

        print "Queuing job..."
        jobman.queueJob(genie3)

        print jobman.queue
        print "Running queue..."
        jobman.runQueue()
        jobman.waitToClear()

        print "Queue finished"
        job = jobman.finished[0]
        print job.alg.gene_list
        print job.alg.read_output(settings)
        jobnet = job.alg.network
        print "PREDICTED NETWORK:"
        print job.alg.network.network
        print jobnet.original_network

        if goldnet_file != None:
            goldnet = Network()
            goldnet.read_goldstd(goldnet_file)
            print "GOLD NETWORK:"
            print goldnet.network
            print jobnet.analyzeMotifs(goldnet).ToString()
            print jobnet.calculateAccuracy(goldnet)

        return jobnet.original_network
os.mkdir(settings["global"]["output_dir"])

# Read in the gold standard network
#goldnet = Network()
#goldnet.read_goldstd(settings["global"]["small_network_goldnet_file"])

#Get a list of the knockout files
#ko_file = settings["global"]["small_network_knockout_file"].split()
#kd_file = settings["global"]["small_network_knockdown_file"].split()
#ts_file = settings["global"]["small_network_timeseries_file"].split()

#wt_file = settings["global"]["small_network_wildtype_file"].split()

# Read in the gold standard network
goldnet = Network()
goldnet.read_goldstd(settings["global"]["large_network_goldnet_file"])

ko_file = settings["global"]["large_network_knockout_file"].split()
kd_file = settings["global"]["large_network_knockdown_file"].split()
ts_file = settings["global"]["large_network_timeseries_file"].split()

wt_file = settings["global"]["large_network_wildtype_file"].split()

# Read data into program
# Where the format is "FILENAME" "DATATYPE"
knockout_storage = ReadData(ko_file[0], "knockout")
knockdown_storage = ReadData(kd_file[0], "knockdown")
timeseries_storage = ReadData(ts_file[0], "timeseries")
wildtype_storage = ReadData(wt_file[0], "wildtype")
wildtype_storage.combine(knockout_storage)
wildtype_storage.combine(knockdown_storage)
    wildtypes[name] = ReadData(exp_data_directory + '/' + name + '/' + wildtype_filename, "wildtype")
    #wildtypes[name].normalize()
    multifactorials[name] = ReadData(exp_data_directory + '/' + name + '/' + multifactorial_filename, "multifactorial")
    #multifactorials[name].normalize()
    goldnets[name] = exp_data_directory + '/' + name + '/' + goldstandard_filename

jobman = JobManager(settings)



# Get TFS from the goldstandard
tfs = {}
for name in data.keys():
    t = []
    goldnet = Network()
    goldnet.read_goldstd(goldnets[name])
    for gene1 in goldnet.network:
        for gene2 in goldnet.network[gene1]:
            if goldnet.network[gene1][gene2] > 0:
                t.append(gene1)
    tfs[name] = list(set(t))

goldnet = Network()
goldnet.read_goldstd(goldnets[data.keys()[0]])



genie3nets = {}
ts_storage = data[name]
settings["global"]["time_series_delta_t"] = (1008.0 / (len(ts_storage[0].experiments)-1))
#combined = timeseries_as_steady_state[name][0]
from JobManager import *
from Network import *
from Generate_Grid import *

from tdaracne import *
from dfg4grn import *
from banjo import *

from ReadConfig import *

settings = {}
settings = ReadConfig(settings)
settings["global"]["working_dir"] = os.getcwd() + "/"

goldnet = Network()
goldnet.read_goldstd("datasets/dream4_10/dream4_10_gold.tsv")

# Create date string to append to output_dir
t = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
settings["global"]["output_dir"] = (
    settings["global"]["output_dir"] + "/" + settings["global"]["experiment_name"] + "-" + t + "/"
)
os.mkdir(settings["global"]["output_dir"])

ts_filenames = settings["global"]["time_series_files"].split()
delta_t = [50] * 20
settings["global"]["time_series_delta_t"] = delta_t

# Read data into program
timeseries_storage = ReadData(ts_filenames[0], True)
    def run(self, kofile, tsfile, wtfile, datafiles, name, goldnet_file, normalize=False):
        os.chdir(os.environ["gene_path"])
        knockout_storage = ReadData(kofile, "knockout")
        print "Reading in knockout data"
        wildtype_storage = ReadData(wtfile, "steadystate")

        if datafiles == []:
          other_storage = None
        else:
          other_storage = ReadData(datafiles[0], "steadystate")
          for file in datafiles[1:]:
              other_storage.combine(ReadData(file, "steadystate"))

        timeseries_storage = None
        if tsfile != None:
            timeseries_storage = ReadData(tsfile, "timeseries")
            #for ts in timeseries_storage:
                #ts.normalize()

        #if normalize:
            #knockout_storage.normalize()
            #wildtype_storage.normalize()
            #other_storage.normalize()


        settings = {}
        settings = ReadConfig(settings)
        # TODO: CHANGE ME
        settings["global"]["working_dir"] = os.getcwd() + '/'

        # Setup job manager
        print "Starting new job manager"
        jobman = JobManager(settings)

        # Make inferelator jobs
        inferelatorjob = inferelator()
        inferelatorjob.setup(knockout_storage, wildtype_storage, settings, timeseries_storage, other_storage, name)

        print "Queuing job..."
        jobman.queueJob(inferelatorjob)

        print jobman.queue
        print "Running queue..."
        jobman.runQueue()
        jobman.waitToClear()

        print "Queue finished"
        job = jobman.finished[0]
        #print job.alg.gene_list
        #print job.alg.read_output(settings)
        jobnet = job.alg.network
        #print "PREDICTED NETWORK:"
        #print job.alg.network.network
        print jobnet.original_network

        if goldnet_file != None:
            goldnet = Network()
            goldnet.read_goldstd(goldnet_file)
            #print "GOLD NETWORK:"
            #print goldnet.network
            #print jobnet.analyzeMotifs(goldnet).ToString()
            print jobnet.calculateAccuracy(goldnet)
            import AnalyzeResults
            tprs, fprs, rocs = AnalyzeResults.GenerateMultiROC(jobman.finished, goldnet )
            ps, rs, precs = AnalyzeResults.GenerateMultiPR(jobman.finished, goldnet)
            print "Area Under ROC"
            print rocs

            print "Area Under PR"
            print precs

        return jobnet.original_network
#pert_data = ReadData(exp_data_directory + "/" + exp_set + "/" + '/TS/' + multifactorial_filename, "multifactorial")
#multifactorials.normalize()
ts_pert_data["goldnet_file"] = exp_data_directory + "/" + exp_set + "/" + '/TS/' + goldstandard_filename

ko_pert_data["ss_data"] = ReadData(exp_data_directory + "/" + exp_set + "/" + '/TS/' + wildtype_filename, "wildtype")
ko_pert_data["multifactorial_data"] = ReadData(exp_data_directory + "/" + exp_set + "/" + '/TS/' + multifactorial_filename, "multifactorial")
ko_pert_data["knockout_data"] = ReadData(exp_data_directory + "/" + exp_set + "/" + '/TS/' + knockout_filename, "knockout")
ko_pert_data["combined"] = ReadData(exp_data_directory + "/" + exp_set + "/" + '/TS/' + knockout_filename, "knockout")
ko_pert_data["combined"].combine(ko_pert_data["multifactorial_data"])

pert_data["multifactorial_data"] = ReadData(exp_data_directory + "/" + exp_set + "/" + '/TS/' + multifactorial_filename, "multifactorial")
pert_data["knockout_data"] = ReadData(exp_data_directory + "/" + exp_set + "/" + '/TS/' + knockout_filename, "knockout")


goldnet = Network()
goldnet.read_goldstd(ts_pert_data["goldnet_file"])

######################
# Clip down the pert data so it is the correct size for the exp
######################
# This is the num for everything to use
ts_only_data["timeseries"] = [ts_only_data["timeseries"][0]]

ts_data_num_exp = len(ts_only_data["timeseries"]) * len(ts_only_data["timeseries"][0].experiments)

ts_only_data["multifactorial_data"].experiments = ts_only_data["multifactorial_data"].experiments[0:len(ts_only_data["multifactorial_data"].experiments) - ts_data_num_exp]

ts_pert_data["timeseries"] = ts_pert_data["timeseries"][0:len(ts_pert_data["timeseries"]) / 2]

num_ts_pert = len(ts_pert_data["timeseries"]) * len(ts_pert_data["timeseries"][0].experiments)
예제 #7
0
    def run(self, datafiles=None, name=None, goldnet_file=None, topd=None, restk=None):
        import numpy

        os.chdir(os.environ["gene_path"])

        print "Reading in data"
        data_storage = ReadData(datafiles[0], "steadystate")
        for file in datafiles[1:]:
            data_storage.combine(ReadData(file, "steadystate"))

        settings = {}
        settings = ReadConfig(settings)
        # TODO: CHANGE ME
        settings["global"]["working_dir"] = os.getcwd() + "/"

        # Setup job manager
        print "Starting new job manager"
        jobman = JobManager(settings)

        # Make nir jobs
        nirjob = NIR()
        nirjob.setup(data_storage, settings, name, topd, restk)

        print "Queuing job..."
        jobman.queueJob(nirjob)

        print jobman.queue
        print "Running queue..."
        jobman.runQueue()
        jobman.waitToClear()

        print "Queue finished"
        job = jobman.finished[0]
        print job.alg.gene_list
        print job.alg.read_output(settings)
        jobnet = job.alg.network
        print "PREDICTED NETWORK:"
        print job.alg.network.network

        if goldnet_file != None:
            goldnet = Network()
            goldnet.read_goldstd(goldnet_file)
            # print "GOLD NETWORK:"
            # print goldnet.network
            # print jobnet.analyzeMotifs(goldnet).ToString()
            print jobnet.calculateAccuracy(goldnet)
            import AnalyzeResults

            tprs, fprs, rocs = AnalyzeResults.GenerateMultiROC(
                jobman.finished, goldnet, True, job.alg.output_dir + "/ROC.pdf"
            )
            ps, rs, precs = AnalyzeResults.GenerateMultiPR(
                jobman.finished, goldnet, True, job.alg.output_dir + "/PR.pdf"
            )
            print "Area Under ROC"
            print rocs

            print "Area Under PR"
            print precs

        return job.alg.network.network
예제 #8
0

# Create date string to append to output_dir
t = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
settings["global"]["output_dir"] = settings["global"]["output_dir"] + "/" + \
    settings["global"]["experiment_name"] + "-" + t + "/"
os.mkdir(settings["global"]["output_dir"])

# Read in the gold standard network

# Read in the gold standard network
goldnet = Network()
#goldnet.read_goldstd(settings["global"]["large_network_goldnet_file"])

if sys.argv[1] == "small":
    goldnet.read_goldstd(settings["global"]["small_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["small_network_knockout_file"].split()
    kd_file = settings["global"]["small_network_knockdown_file"].split()
    ts_file = settings["global"]["small_network_timeseries_file"].split()
    wt_file = settings["global"]["small_network_wildtype_file"].split()

if sys.argv[1] == "medium":
    goldnet.read_goldstd(settings["global"]["medium_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["medium_network_knockout_file"].split()
    kd_file = settings["global"]["medium_network_knockdown_file"].split()
    ts_file = settings["global"]["medium_network_timeseries_file"].split()
    wt_file = settings["global"]["medium_network_wildtype_file"].split()

if sys.argv[1] == "medium2":
# Instantsiate settings file
settings = {}
settings = ReadConfig(settings)
settings["global"]["working_dir"] = os.getcwd() + '/'



# Create date string to append to output_dir
t = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
settings["global"]["output_dir"] = settings["global"]["output_dir"] + "/" + \
    settings["global"]["experiment_name"] + "-" + t + "/"
os.mkdir(settings["global"]["output_dir"])

# Read in the gold standard network
goldnet = Network()
goldnet.read_goldstd(settings["global"]["medium_network_goldnet_file"])

#Get a list of the knockout files
ko_file = settings["global"]["medium_network_knockout_file"].split()
kd_file = settings["global"]["medium_network_knockdown_file"].split()
ts_file = settings["global"]["medium_network_timeseries_file"].split()

wt_file = settings["global"]["medium_network_wildtype_file"].split()

# Read in the gold standard network
#goldnet = Network()
#goldnet.read_goldstd(settings["global"]["large_network_goldnet_file"])

#ko_file = settings["global"]["large_network_knockout_file"].split()
#kd_file = settings["global"]["large_network_knockdown_file"].split()
#ts_file = settings["global"]["large_network_timeseries_file"].split()
from JobManager import *
from Network import *
from Generate_Grid import *

def get_immediate_subdirectories(dir):
    return [name for name in os.listdir(dir) if os.path.isdir(os.path.join(dir, name))]

sys.path += get_immediate_subdirectories("./")

from ReadConfig import *
settings = {}
settings = ReadConfig(settings)
settings["global"]["working_dir"] = os.getcwd() + '/'

goldnet = Network()
goldnet.read_goldstd(settings["global"]["small_network_goldnet_file"])

# Create date string to append to output_dir
t = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
settings["global"]["output_dir"] = settings["global"]["output_dir"] + "/" + \
    settings["global"]["experiment_name"] + "-" + t + "/"
os.mkdir(settings["global"]["output_dir"])

knockdown_filenames = settings["global"]["small_network_knockdown_file"].split()

knockdown_storage = ReadData(knockdown_filenames[0], "knockdown")

from nirest import *

settings = ReadConfig(settings, "./config/default_values/nirest.cfg")
settings = ReadConfig(settings, settings["nirest"]["config"])
예제 #11
0
def get_example_data_files(name, settings):
  # Read in gold standard network
  goldnet = Network()

  dko_file = None

  if name == "small":
    goldnet.read_goldstd(settings["global"]["small_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["small_network_knockout_file"].split()
    kd_file = settings["global"]["small_network_knockdown_file"].split()
    ts_file = settings["global"]["small_network_timeseries_file"].split()
    wt_file = settings["global"]["small_network_wildtype_file"].split()
    mf_file = settings["global"]["small_network_multifactorial_file"].split()

  elif name == "medium":
    goldnet.read_goldstd(settings["global"]["medium_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["medium_network_knockout_file"].split()
    kd_file = settings["global"]["medium_network_knockdown_file"].split()
    ts_file = settings["global"]["medium_network_timeseries_file"].split()
    wt_file = settings["global"]["medium_network_wildtype_file"].split()
    mf_file = settings["global"]["medium_network_multifactorial_file"].split()

  elif name == "medium_2":
    goldnet.read_goldstd(settings["global"]["medium2_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["medium2_network_knockout_file"].split()
    kd_file = settings["global"]["medium2_network_knockdown_file"].split()
    ts_file = settings["global"]["medium2_network_timeseries_file"].split()
    wt_file = settings["global"]["medium2_network_wildtype_file"].split()
    mf_file = settings["global"]["medium2_network_multifactorial_file"].split()

  elif name == "dream410":
    goldnet.read_goldstd(settings["global"]["dream410_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream410_network_knockout_file"].split()
    kd_file = settings["global"]["dream410_network_knockdown_file"].split()
    ts_file = settings["global"]["dream410_network_timeseries_file"].split()
    wt_file = settings["global"]["dream410_network_wildtype_file"].split()
    mf_file = settings["global"]["dream410_network_multifactorial_file"].split()
    dko_file = settings["global"]["dream410_network_doubleknockout_file"].split()
    dko_idx_file = settings["global"]["dream410_network_doubleknockout_index_file"].split()

  elif name == "dream410_2":
    goldnet.read_goldstd(settings["global"]["dream410_2_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream410_2_network_knockout_file"].split()
    kd_file = settings["global"]["dream410_2_network_knockdown_file"].split()
    ts_file = settings["global"]["dream410_2_network_timeseries_file"].split()
    wt_file = settings["global"]["dream410_2_network_wildtype_file"].split()
    mf_file = settings["global"]["dream410_2_network_multifactorial_file"].split()

  elif name == "dream410_3":
    goldnet.read_goldstd(settings["global"]["dream410_3_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream410_3_network_knockout_file"].split()
    kd_file = settings["global"]["dream410_3_network_knockdown_file"].split()
    ts_file = settings["global"]["dream410_3_network_timeseries_file"].split()
    wt_file = settings["global"]["dream410_3_network_wildtype_file"].split()
    mf_file = settings["global"]["dream410_3_network_multifactorial_file"].split()

  elif name == "dream410_4":
    goldnet.read_goldstd(settings["global"]["dream410_4_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream410_4_network_knockout_file"].split()
    kd_file = settings["global"]["dream410_4_network_knockdown_file"].split()
    ts_file = settings["global"]["dream410_4_network_timeseries_file"].split()
    wt_file = settings["global"]["dream410_4_network_wildtype_file"].split()
    mf_file = settings["global"]["dream410_4_network_multifactorial_file"].split()

  elif name == "dream410_5":
    goldnet.read_goldstd(settings["global"]["dream410_5_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream410_5_network_knockout_file"].split()
    kd_file = settings["global"]["dream410_5_network_knockdown_file"].split()
    ts_file = settings["global"]["dream410_5_network_timeseries_file"].split()
    wt_file = settings["global"]["dream410_5_network_wildtype_file"].split()
    mf_file = settings["global"]["dream410_5_network_multifactorial_file"].split()

  elif name == "dream4100":
    goldnet.read_goldstd(settings["global"]["dream4100_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream4100_network_knockout_file"].split()
    kd_file = settings["global"]["dream4100_network_knockdown_file"].split()
    ts_file = settings["global"]["dream4100_network_timeseries_file"].split()
    wt_file = settings["global"]["dream4100_network_wildtype_file"].split()
    mf_file = settings["global"]["dream4100_network_multifactorial_file"].split()

  elif name == "dream4100_2":
    goldnet.read_goldstd(settings["global"]["dream4100_2_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream4100_2_network_knockout_file"].split()
    kd_file = settings["global"]["dream4100_2_network_knockdown_file"].split()
    ts_file = settings["global"]["dream4100_2_network_timeseries_file"].split()
    wt_file = settings["global"]["dream4100_2_network_wildtype_file"].split()
    mf_file = settings["global"]["dream4100_2_network_multifactorial_file"].split()

  elif name == "dream4100_3":
    goldnet.read_goldstd(settings["global"]["dream4100_3_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream4100_3_network_knockout_file"].split()
    kd_file = settings["global"]["dream4100_3_network_knockdown_file"].split()
    ts_file = settings["global"]["dream4100_3_network_timeseries_file"].split()
    wt_file = settings["global"]["dream4100_3_network_wildtype_file"].split()
    mf_file = settings["global"]["dream4100_3_network_multifactorial_file"].split()

  elif name == "dream4100_4":
    goldnet.read_goldstd(settings["global"]["dream4100_4_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream4100_4_network_knockout_file"].split()
    kd_file = settings["global"]["dream4100_4_network_knockdown_file"].split()
    ts_file = settings["global"]["dream4100_4_network_timeseries_file"].split()
    wt_file = settings["global"]["dream4100_4_network_wildtype_file"].split()
    mf_file = settings["global"]["dream4100_4_network_multifactorial_file"].split()

  elif name == "dream4100_5":
    goldnet.read_goldstd(settings["global"]["dream4100_5_network_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["dream4100_5_network_knockout_file"].split()
    kd_file = settings["global"]["dream4100_5_network_knockdown_file"].split()
    ts_file = settings["global"]["dream4100_5_network_timeseries_file"].split()
    wt_file = settings["global"]["dream4100_5_network_wildtype_file"].split()
    mf_file = settings["global"]["dream4100_5_network_multifactorial_file"].split()

  elif name == "ecoli400":
    goldnet.read_goldstd(settings["global"]["ecoli400_goldnet_file"])
    #Get a list of the knockout files
    ko_file = settings["global"]["ecoli400_knockout_file"].split()
    kd_file = settings["global"]["ecoli400_knockdown_file"].split()
    ts_file = settings["global"]["ecoli400_timeseries_file"].split()
    wt_file = settings["global"]["ecoli400_wildtype_file"].split()
    mf_file = settings["global"]["ecoli400_multifactorial_file"].split()

  else:
    print "ERROR: Dataset {0} not found, exiting.".format(name)
    exit()
  if dko_file != None:
    return ko_file, kd_file, ts_file, wt_file, mf_file, goldnet, dko_file, dko_idx_file
  else:
    return ko_file, kd_file, ts_file, wt_file, mf_file, goldnet
    wildtypes[name] = ReadData(exp_data_directory + '/' + name + '/' + wildtype_filename, "wildtype")
    #wildtypes[name].normalize()
    multifactorials[name] = ReadData(exp_data_directory + '/' + name + '/' + multifactorial_filename, "multifactorial")
    #multifactorials[name].normalize()
    goldnets[name] = exp_data_directory + '/' + name + '/' + goldstandard_filename



jobman = JobManager(settings)

# Get TFS from the goldstandard
tfs = {}
for name in data.keys():
    t = []
    goldnet = Network()
    goldnet.read_goldstd(goldnets[name])
    for gene1 in goldnet.network:
        for gene2 in goldnet.network[gene1]:
            if goldnet.network[gene1][gene2] > 0:
                t.append(gene1)
    tfs[name] = list(set(t))

goldnet = Network()
goldnet.read_goldstd(goldnets[exp_name])


ts_storage = data[exp_name]
settings["global"]["time_series_delta_t"] = int((1008.0 / (len(ts_storage[0].experiments)-1)))
print settings["global"]["time_series_delta_t"]

from tdaracne import *



from ReadConfig import *
# Initialize settings file
settings = {}
settings = ReadConfig(settings)
settings["global"]["working_dir"] = os.getcwd() + '/'
settings["global"]["experiment_name"] = "TDARACNE-"+sys.argv[1]
if len(sys.argv) > 2:
  settings["global"]["experiment_name"] += "-" + sys.argv[2]

goldnet = Network()
goldnet.read_goldstd("datasets/dream4_10/dream4_10_gold.tsv")

# Create date string to append to output_dir
t = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
settings["global"]["output_dir"] = settings["global"]["output_dir"] + "/" + \
    settings["global"]["experiment_name"] + "-" + t + "/"
os.mkdir(settings["global"]["output_dir"])

# Read in the gold standard network

# Read in the gold standard network
goldnet = Network()
#goldnet.read_goldstd(settings["global"]["large_network_goldnet_file"])

if sys.argv[1] == "small":
    goldnet.read_goldstd(settings["global"]["small_network_goldnet_file"])
    settings["global"]["output_dir"] + "/" + settings["global"]["experiment_name"] + "-" + t + "/"
)
os.mkdir(settings["global"]["output_dir"])

# Read in the gold standard network

# Read in the gold standard network
goldnet = Network()
# goldnet.read_goldstd(settings["global"]["large_network_goldnet_file"])
# ko_file, kd_file, ts_file, wt_file, mf_file, goldnet = get_example_data_files(sys.argv[1], settings)

ko_file = "algorithms/genenetweaver/InSilicoSize10-Ecoli1_knockouts.tsv"
kd_file = "algorithms/genenetweaver/InSilicoSize10-Ecoli1_knockdowns.tsv"
wt_file = "algorithms/genenetweaver/InSilicoSize10-Ecoli1_wildtype.tsv"
ts_file = "algorithms/genenetweaver/InSilicoSize10-Ecoli1_dream4_timeseries.tsv"
goldnet.read_goldstd("algorithms/genenetweaver/InSilicoSize10-Ecoli1_goldstandard.tsv")


# Read data into program
# Where the format is "FILENAME" "DATATYPE"
knockout_storage = ReadData(ko_file, "knockout")
knockdown_storage = ReadData(kd_file, "knockdown")
timeseries_storage = ReadData(ts_file, "timeseries")
wildtype_storage = ReadData(wt_file, "wildtype")


# Setup job manager
jobman = JobManager(settings)

# Make MCZ job
mczjob = MCZ()
from JobManager import *
from Network import *
from Generate_Grid import *

def get_immediate_subdirectories(dir):
    return [name for name in os.listdir(dir) if os.path.isdir(os.path.join(dir, name))]

sys.path += get_immediate_subdirectories("./")

from ReadConfig import *
settings = {}
settings = ReadConfig(settings)
settings["global"]["working_dir"] = os.getcwd() + '/'

goldnet = Network()
goldnet.read_goldstd("datasets/Small_Network/Ecoli-1_goldstandard.tsv")
print goldnet.network

# Create date string to append to output_dir
t = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
settings["global"]["output_dir"] = settings["global"]["output_dir"] + "/" + \
    settings["global"]["experiment_name"] + "-" + t + "/"
os.mkdir(settings["global"]["output_dir"])

settings["global"]["time_series_files"] = "datasets/Small_Network/Ecoli-1_dream4_timeseries.tsv"
ts_filenames = settings["global"]["time_series_files"].split()
delta_t = [50]*20
settings["global"]["time_series_delta_t"] = delta_t
#delta_t = settings["global"]["time_series_delta_t"].split()
print delta_t
timeseries_storage = []
    wildtypes[name] = ReadData(exp_data_directory + '/' + name + '/' + wildtype_filename, "wildtype")
    #wildtypes[name].normalize()
    multifactorials[name] = ReadData(exp_data_directory + '/' + name + '/' + multifactorial_filename, "multifactorial")
    #multifactorials[name].normalize()
    goldnets[name] = exp_data_directory + '/' + name + '/' + goldstandard_filename

jobman = JobManager(settings)



# Get TFS from the goldstandard
tfs = {}
for name in data.keys():
    t = []
    goldnet = Network()
    goldnet.read_goldstd(goldnets[name])
    for gene1 in goldnet.network:
        for gene2 in goldnet.network[gene1]:
            if goldnet.network[gene1][gene2] > 0:
                t.append(gene1)
    tfs[name] = list(set(t))

for key in goldnets.keys():
    goldnet = Network()
    goldnet.read_goldstd(goldnets[key])
    goldnets[key] = goldnet



genie3nets = {}
for i in range(20):
#for ts in data:
    #ts.normalize()
knockouts = ReadData(exp_data_directory + '/' + knockout_filename, "knockout")
#knockouts.normalize()
knockdowns = ReadData(exp_data_directory + '/' + knockdown_filename, "knockdown")
#knockdowns.normalize()
ss_data = ReadData(exp_data_directory + '/' + wildtype_filename, "wildtype")
#wildtypes.normalize()
multifactorial_data = ReadData(exp_data_directory + '/' + multifactorial_filename, "multifactorial")
#pert_data = ReadData(exp_data_directory + '/' + multifactorial_filename, "multifactorial")
pert_data = ReadData(exp_data_directory + '/' + knockout_filename, "knockout")
#multifactorials.normalize()
goldnet_file = exp_data_directory + '/' + goldstandard_filename

goldnet = Network()
goldnet.read_goldstd(goldnet_file)

# Initialize settings file
settings = {}
settings = ReadConfig(settings)
settings["global"]["working_dir"] = os.getcwd() + '/'
settings["global"]["experiment_name"] = "Kranthi-SimDex-NBoot-{0}".format(nboot)

settings["global"]["n_processors"] = 1

# Set up output directory
t = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
settings["global"]["output_dir"] = settings["global"]["output_dir"] + "/" + \
    settings["global"]["experiment_name"] + "-" + t + "/"
os.mkdir(settings["global"]["output_dir"])