Beispiel #1
0
def WaitForAssembly(proglist):
   ''' Checking the status of the assembler, and waiting for it to finish if
   it is still running. '''
   # Verify that assembly is submitted
   if proglist.Exists('Assembler'):
      status = proglist['Assembler'].GetStatus()
      if status == 'Executing':
         printDebug("\nWaiting for Assembly to finish...") #DEBUG
         proglist['Assembler'].WaitOn(pattern='Done', ePattern='Error')
         status = proglist['Assembler'].GetStatus()
         # THE SUCCESS OF THE ASSEMBLY IS VALIDATED
         if status == 'Done':
            printNsave(template_line%'The Assembly was finished...')
            # Retrieve contigs path
            contig_data = RetrieveContigsInfo(args.usr, args.token, isolateID)
            if contig_data is not None:
               path, fid = contig_data
               # Removing the gz extension
               if path[-3:]=='.gz': path = path[:-3]
               # Checking if the file exists as normal or gzipped file
               if os.path.exists(path):
                  paths.add_path('contigs', path)
               elif os.path.exists(path+'.gz'):
                  paths.add_path('contigs', path+'.gz')
               else:
                  printDebug("Contigs could not be found! (%s)"%(path))
                  printNsave(template_line%'The contigs file could not be found!')
                  status = 'Failure'
                  proglist['Assembler'].status = status
            else:
               printNsave(template_line%'No suitable contigs was created by the assembler!')
               status = 'Failure'
               proglist['Assembler'].status = status
      if status == 'Done': return True, fid
      else: return False, None
   else:
      return True, None
Beispiel #2
0
   proglist.Add2List(assembler)
   printNsave(template_line%'Assembler was executed according to plan...')
else:
   # Validate that only 1 file was submitted
   if len(inputFiles) != 1:
      printDebug("Error: Invalid number of contig files (%s)\n"%(len(inputFiles)))
      sys.exit(1)
   # Validate that the uploaded file is fasta
   if CheckFileType(inputFiles[0]) != 'fasta':
      printDebug("Error: Invalid contigs format (%s)!\nOnly the fasta format is recognised as a proper contig format.\n"%
(CheckFileType(inputFiles[0])))
      sys.exit(1)
   # Add mySQL entry for the contigs
   fid = AddFile2DB(isolateID, None, args.usr, 'contigs', inputFiles[0], 'Preassembled contigs')
   # Add the contigs path to the paths object
   paths.add_path('contigs', inputFiles[0])

# SPECIES TYPING
predicted_species = 'unknown'
if 'KmerFinder' in speciestyping: # KmerFinder
   kmerfinder = program(name='KmerFinder',
      ptype=None, path=paths['programRoot']+'KmerFinder-2.1.py',
      workDir=paths['services'], ssh=False, toQueue=False, wait=False,
      args=['--iid',   isolateID,
            '--ip',    args.ip,
            '--usr',   args.usr,
            '--token', args.token,
            '-s',      args.KFscoring,
            '-d',      args.KFdatabase
            ]
      )