Пример #1
0
    def read_output(self,settings):
      # Code to write for collecting the output files from the algorithm, writes to the
      # output list in the object
      # What we want to do here is get the prediction rate on the last time
      # point and the network so we can compare it against a gold std.
      # This file is a bunch of zscores, so we have to load the cutoff we want
      output_file = open(self.output_dir + "/output/ranked_edges.txt", 'r')
      topn = None
      if "top_n_edges" in settings["genie3"].keys():
        topn = settings["genie3"]["top_n_edges"]
      else:
        topn = len(self.gene_list)
      zscores = []
      for line in output_file:
          gene1, gene2, zscore = line.split()
          zscore = float(zscore)
          zscores.append((gene1, gene2, zscore))
      zscores = sorted(zscores, key=lambda zscore: abs(zscore[2]), reverse=True)

      self.zscores = zscores[:]
      network = []

      #for i,zscore in enumerate(zscores):
          #if i < topn:
            #gene1, gene2, zscore = zscore
            #zscores[i] = (gene1, gene2, 1)
          #else:
            #gene1, gene2, zscore = zscore
            #zscores[i] = (gene1, gene2, 0)
      net = Network()
      net.read_networklist(zscores)
      net.gene_list = self.gene_list
      self.network = net

      return self.zscores
Пример #2
0
    def read_output(self,settings):
        # Code to write for collecting the output files from the algorithm, writes to the
      # output list in the object
      # What we want to do here is get the prediction rate on the last time
      # point and the network so we can compare it against a gold std.
      # This file is a bunch of zscores, so we have to load the cutoff we want
      output_file = open(self.output_dir + "/output/mcz_output.txt", 'r')

      output_file = output_file.readlines()
      zscores = []
      for g1, line in enumerate(output_file[1:]):
          for g2, val in enumerate(line.split('\t')[1:]):
              zscores.append((self.gene_list[g2], self.gene_list[g1], float(line.split()[1:][g2])))
      topn = settings["mcz"]["top_n_edges"]
      #for line in output_file:
          #gene1, gene2, zscore = line.split()
          #zscore = float(zscore)
          #zscores.append((gene1, gene2, zscore))
      zscores = sorted(zscores, key=lambda zscore: abs(zscore[2]), reverse=True)

      self.zscores = zscores[:]
      network = []

      #for i,zscore in enumerate(zscores):
          #if i < topn:
            #gene1, gene2, zscore = zscore
            #if zscore > 0:
                #zscores[i] = (gene1, gene2, 1)
            #if zscore < 0:
                #zscores[i] = (gene1, gene2, -1)

          #else:
            #gene1, gene2, zscore = zscore
            #zscores[i] = (gene1, gene2, 0)
      net = Network()
      net.read_networklist(zscores)
      net.gene_list = self.gene_list
      self.network = net

      return self.network