def gather(): util.debug("Gathering result") job_results = results paths.ensure(job_results) #aazj00103_05.075_v1_3.bz2 zj001.fasta zj001.psipred_ss2 #aazj00109_05.075_v1_3.bz2 zj001.psipred aa_pattern = "aa"+name+"(03|09)\_05\.075\_v1\_3$" patterns = [aa_pattern] for suf in [".fasta", ".psipred", ".psipred_ss2"]: patterns.append(name+suf) try: for pattern in patterns: print "Pattern ",pattern match = paths.find(pattern, scr_job) if not match: raise "Missing file" for path in match: if pattern == aa_pattern: print "Filtering Columns %s" % path for line in fileinput.input(path, inplace=1): print " "+line[:47].strip() fileinput.close() print "Path ", path file = paths.getFile(path) dest = paths.join(job_results, file) util.copy(path, job_results) if pattern == aa_pattern: util.system("bzip2 %s" % dest) except: paths.removerf(job_results) raise
def gather(): util.debug("Gathering result") job_results = results paths.ensure(job_results) #aazj00103_05.075_v1_3.bz2 zj001.fasta zj001.psipred_ss2 #aazj00109_05.075_v1_3.bz2 zj001.psipred aa_pattern = "aa" + name + "(03|09)\_05\.075\_v1\_3$" patterns = [aa_pattern] for suf in [".fasta", ".psipred", ".psipred_ss2"]: patterns.append(name + suf) try: for pattern in patterns: print "Pattern ", pattern match = paths.find(pattern, scr_job) if not match: raise "Missing file" for path in match: if pattern == aa_pattern: print "Filtering Columns %s" % path for line in fileinput.input(path, inplace=1): print " " + line[:47].strip() fileinput.close() print "Path ", path file = paths.getFile(path) dest = paths.join(job_results, file) util.copy(path, job_results) if pattern == aa_pattern: util.system("bzip2 %s" % dest) except: paths.removerf(job_results) raise
def tasks(decoy_dir, psipred_dir): from hpf.utilities.paths import find runtime().debug("Searching for decoys",decoy_dir) decoys = list(find("[a-z]{2}[0-9]{3}\.((result)|(out))\.gz",dir=decoy_dir)) runtime().debug("Found",len(decoys),"decoys") for decoy in decoys: prediction_code = pred_code(decoy) psipred = os.path.join(psipred_dir,prediction_code,prediction_code+".psipred") if os.path.exists(psipred): yield (decoy,psipred)
def gather(): global code, task_id utilities.debug("Gathering result") paths.ensure(results_dir) # Contents of results directory (3' library, 9' library, fasta, psipred, and psipred_ss2 files). EG: #aazj00103_05.075_v1_3.bz2 zj001.fasta zj001.psipred_ss2 #aazj00109_05.075_v1_3.bz2 zj001.psipred # Set "patterns" for results files. aa_pattern = "aa"+code+task_id+"(03|09)\_05\.075\_v1\_3$" patterns = [aa_pattern] for suf in [".fasta", ".psipred", ".psipred_ss2"]: patterns.append(code+task_id+suf) try: for pattern in patterns: print "Pattern ",pattern # Find the results file in scr_job_dir match = paths.find(pattern, scr_job_dir) # If a results file matching pattern is not found in the scr_jobs_dir, raise exception. if not match: raise "Missing file" # Copy all results files in scr_job_dir to results_dir. for path in match: # If the results file is a frag library, format the frag library file. if pattern == aa_pattern: print "Filtering Columns of file %s" % path # fileinput.input opens a file for iteration. Defining inplace=1 allows to given file to be # altered "in place": file is backed up, and stdout is then directed to the file. # Filters the file: writes " " + first 47 chars of the line. (Specific formatting). for line in fileinput.input(path, inplace=1): print " "+line[:47].strip() fileinput.close() print "Path ", path # Copy the result file to results_dir. utilities.copy(path, results_dir) # If the results file is a frag library, bzip it in the results_dir. if pattern == aa_pattern: dest = paths.join(results_dir, paths.getFile(path)) utilities.system("bzip2 %s" % dest) # If gathering the results files fails, delete the results_dir and exit. except: paths.removerf(results_dir) raise
def gather(): global code, task_id utilities.debug("Gathering result") paths.ensure(results_dir) # Contents of results directory (3' library, 9' library, fasta, psipred, and psipred_ss2 files). EG: #aazj00103_05.075_v1_3.bz2 zj001.fasta zj001.psipred_ss2 #aazj00109_05.075_v1_3.bz2 zj001.psipred # Set "patterns" for results files. aa_pattern = "aa" + code + task_id + "(03|09)\_05\.075\_v1\_3$" patterns = [aa_pattern] for suf in [".fasta", ".psipred", ".psipred_ss2"]: patterns.append(code + task_id + suf) try: for pattern in patterns: print "Pattern ", pattern # Find the results file in scr_job_dir match = paths.find(pattern, scr_job_dir) # If a results file matching pattern is not found in the scr_jobs_dir, raise exception. if not match: raise "Missing file" # Copy all results files in scr_job_dir to results_dir. for path in match: # If the results file is a frag library, format the frag library file. if pattern == aa_pattern: print "Filtering Columns of file %s" % path # fileinput.input opens a file for iteration. Defining inplace=1 allows to given file to be # altered "in place": file is backed up, and stdout is then directed to the file. # Filters the file: writes " " + first 47 chars of the line. (Specific formatting). for line in fileinput.input(path, inplace=1): print " " + line[:47].strip() fileinput.close() print "Path ", path # Copy the result file to results_dir. utilities.copy(path, results_dir) # If the results file is a frag library, bzip it in the results_dir. if pattern == aa_pattern: dest = paths.join(results_dir, paths.getFile(path)) utilities.system("bzip2 %s" % dest) # If gathering the results files fails, delete the results_dir and exit. except: paths.removerf(results_dir) raise
def _gather(self): """Gather result files and report text file.""" from hpf.utilities.paths import ensure, find scr_results_dir = self.decoy_file+".p" results = os.path.join(self.results,self.job_name) ensure(results) # Using the full filename will ensure the directory is created. shutil.copy(os.path.join(scr_results_dir, "log.xml"), results) decoys = list(find("decoy\_[0-9]+\.pdb",dir=scr_results_dir)) assert len(decoys)>0 for decoy in decoys: shutil.copy(decoy, results) shutil.copy(os.path.join(self.job, "report.txt"), results)