コード例 #1
0
ファイル: workflow.py プロジェクト: bipype/metAMOS
   def read(self, comment = "#"):
      # populate from file
      self.isValid = True

      workflow_file = None
      for p in self.path:
         if os.path.exists("%s%s%s.ini"%(p, os.sep, self.name.lower())):
            workflow_file = open("%s%s%s.ini"%(p, os.sep, self.name.lower()), 'r')
      if workflow_file == None:
         print "Error: cannot open workflow %s"%(self.name)
         raise(JobSignalledBreak)

      lastPos = 0
      while True:
         lastPos = workflow_file.tell()
         line = workflow_file.readline()
         (line, sep, commentLine) = line.partition(comment)
         if len(commentLine) != 0:
            continue

         if "programs:" in line:
            splitLine = line.replace("programs:", "").strip().split()
            for prog in splitLine:
               self.programList.add(prog.lower())
         elif "md5:" in line:
            self.md5 = line.replace("md5:", "").strip()
         elif "inherit:" in line:
            splitLine = line.replace("inherit:", "").strip().split()
            for master in splitLine:
               self.super.append(master)
               masterFlow = None
               if master in _workflows:
                  masterFlow = _workflows[master]
               else:
                  masterFlow = Workflow(line.replace("inherit:", "").strip(), self.path)
                  masterFlow.read()
               self.programList.update(masterFlow.programList)
               self.readlibs.extend(masterFlow.readlibs)
               self.commandList = (masterFlow.commandList + " " + self.commandList).strip()
               self.asmcontigs.extend(masterFlow.asmcontigs)
               self.isModifiable = masterFlow.isModifiable or self.isModifiable
         elif "modify:" in line:
            splitLine = line.replace("modify:", "").strip()
            self.isModifiable = self.isModifiable or str2bool(splitLine)
         elif "command:" in line:
            splitLine = line.replace("command:", "").strip()
            self.commandList = (self.commandList + " " + splitLine).strip()
         else:
            break
      workflow_file.seek(lastPos)

      # now read the library info
      (readasm, readl, ignore) = readConfigInfo(workflow_file)
      self.readlibs.extend(readl)

      self.asmcontigs.extend(readasm)
      workflow_file.close()

      if self.md5 != None:
        if self.md5 != getMD5():
           self.isValid = False
 
      if _verbose:
         print "Read workflow %s"%(self.name)
         print "Inherits from %s"%(",".join(self.super))
         print "Supported programs %s"%(",".join(self.programList))
         print "Asm contigs %s"%(",".join(self.asmcontigs))
         for lib in self.readlibs:
            print "Lib %s %s %s %s %s %s %s %s %s"%(lib.id, lib.format, lib.mean, lib.stdev, lib.mmin, lib.mmax, lib.mated, lib.interleaved, lib.innie) 
コード例 #2
0
ファイル: runPipeline.py プロジェクト: omsai/metAMOS
    elif o in ("-d", "--projectdir"):
        utils.Settings.rundir = os.path.abspath(a)
        if not os.path.exists(a):
            print "project dir %s does not exist!" % (settings.rundir)
            usage()
            sys.exit(1)

if not os.path.exists(settings.rundir) or settings.rundir == "":
    print "project dir %s does not exist!" % (settings.rundir)
    usage()
    sys.exit(1)

inifile = settings.rundir + os.sep + "pipeline.ini"
inf = open(inifile, 'r')
(asmcontigs, readlibs,
 wfName) = utils.readConfigInfo(inf, "%s/Preprocess/in/" % (settings.rundir))

if wfName != "":
    #parse frag/libs out of pipeline.ini out of rundir
    availableWf = workflow.getSupportedWorkflows(
        "%s/workflows" % (utils.INITIAL_UTILS), True)
    availableWf.extend(workflow.getSupportedWorkflows(os.getcwd(), True))
    availableWorkflows = dict()
    for wf in availableWf:
        availableWorkflows[wf.name] = wf

    if wfName.lower() not in availableWorkflows.keys():
        print "Error: unknown workflow %s specified. Please choose one of %s." % (
            wfName, ",".join(availableWorkflows.keys()))
        sys.exit(1)
    wf = availableWorkflows[wfName]
コード例 #3
0
ファイル: runPipeline.py プロジェクト: jgluck/metAMOS
        sys.exit()
    elif o in ("-d", "--projectdir"):
        utils.Settings.rundir = os.path.abspath(a)
        if not os.path.exists(a):
          print "project dir %s does not exist!"%(settings.rundir)
          usage()
          sys.exit(1)

if not os.path.exists(settings.rundir) or settings.rundir == "":
    print "project dir %s does not exist!"%(settings.rundir)
    usage()
    sys.exit(1)

inifile = settings.rundir+os.sep+"pipeline.ini"
inf = open(inifile,'r')
(asmcontigs, readlibs, wfName) = utils.readConfigInfo(inf, "%s/Preprocess/in/"%(settings.rundir))

if wfName != "":
   #parse frag/libs out of pipeline.ini out of rundir
   availableWf = workflow.getSupportedWorkflows("%s/workflows"%(utils.INITIAL_UTILS), True)
   availableWf.extend(workflow.getSupportedWorkflows(os.getcwd(), True))
   availableWorkflows = dict()
   for wf in availableWf:
      availableWorkflows[wf.name] = wf

   if wfName.lower() not in availableWorkflows.keys():
      print "Error: unknown wofkflow %s specified. Please choose one of %s."%(wfName, ",".join(availableWorkflows.keys()))
      sys.exit(1)
   wf = availableWorkflows[wfName]
   try:
      wfopts, wfargs = getopt.getopt(wf.commandList.strip().split(), shortOptions, longOptions)
コード例 #4
0
    def read(self, comment="#"):
        # populate from file
        self.isValid = True

        workflow_file = None
        for p in self.path:
            if os.path.exists("%s%s%s.ini" % (p, os.sep, self.name.lower())):
                workflow_file = open(
                    "%s%s%s.ini" % (p, os.sep, self.name.lower()), 'r')
        if workflow_file == None:
            print "Error: cannot open workflow %s" % (self.name)
            raise (JobSignalledBreak)

        lastPos = 0
        while True:
            lastPos = workflow_file.tell()
            line = workflow_file.readline()
            (line, sep, commentLine) = line.partition(comment)
            if len(commentLine) != 0:
                continue

            if "programs:" in line:
                splitLine = line.replace("programs:", "").strip().split()
                for prog in splitLine:
                    self.programList.add(prog.lower())

            if "steps:" in line:
                self.stepList = []
                splitLine = line.replace("steps:", "").strip().split()
                for step in splitLine:
                    if step not in stepList:
                        self.stepList.append(step.lower())

            elif "md5:" in line:
                self.md5 = line.replace("md5:", "").strip()
            elif "inherit:" in line:
                splitLine = line.replace("inherit:", "").strip().split()
                for master in splitLine:
                    self.super.append(master)
                    masterFlow = None
                    if master in _workflows:
                        masterFlow = _workflows[master]
                    else:
                        masterFlow = Workflow(
                            line.replace("inherit:", "").strip(), self.path)
                        masterFlow.read()
                    self.programList.update(masterFlow.programList)
                    self.readlibs.extend(masterFlow.readlibs)
                    self.commandList = (masterFlow.commandList + " " +
                                        self.commandList).strip()
                    self.asmcontigs.extend(masterFlow.asmcontigs)
                    self.isModifiable = masterFlow.isModifiable or self.isModifiable
            elif "modify:" in line:
                splitLine = line.replace("modify:", "").strip()
                self.isModifiable = self.isModifiable or str2bool(splitLine)
            elif "command:" in line:
                splitLine = line.replace("command:", "").strip()
                self.commandList = (self.commandList + " " + splitLine).strip()
            else:
                break
        workflow_file.seek(lastPos)

        # now read the library info
        (readasm, readl, ignore) = readConfigInfo(workflow_file)
        self.readlibs.extend(readl)

        self.asmcontigs.extend(readasm)
        workflow_file.close()

        if self.md5 != None:
            if self.md5 != getMD5():
                self.isValid = False

        if _verbose:
            print "Read workflow %s" % (self.name)
            print "Inherits from %s" % (",".join(self.super))
            print "Supported programs %s" % (",".join(self.programList))
            print "Asm contigs %s" % (",".join(self.asmcontigs))
            for lib in self.readlibs:
                print "Lib %s %s %s %s %s %s %s %s %s" % (
                    lib.id, lib.format, lib.mean, lib.stdev, lib.mmin,
                    lib.mmax, lib.mated, lib.interleaved, lib.innie)