Mercurial > repos > devteam > ccat
diff ccat_wrapper.py @ 2:1a6979fbd544 draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/ccat commit 1370bb21ee5712a13a26d289065406c5d489b8cc"
author | devteam |
---|---|
date | Fri, 03 Dec 2021 16:27:57 +0000 |
parents | 201d8e7dfc43 |
children |
line wrap: on
line diff
--- a/ccat_wrapper.py Tue Jul 21 14:13:34 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -import sys, subprocess, tempfile, shutil, os.path - -CCAT_BINARY = "CCAT" - -def get_top_count( filename ): - for line in open( filename ): - if line.startswith( 'outputNum' ): - return int( line.split()[-1].strip() ) - -def stop_err( tmp_dir, exception ): - print >> sys.stderr, "Error running CCAT." - shutil.rmtree( tmp_dir ) #some error has occurred, provide info and remove possibly non-empty temp directory - raise exception - -def main(): - input_tag_file = sys.argv[1] - input_control_file = sys.argv[2] - chrom_info_file = sys.argv[3] - input_config_file = sys.argv[4] - project_name = sys.argv[5] - output_peak_file = sys.argv[6] - output_region_file = sys.argv[7] - output_top_file = sys.argv[8] - output_log_file = sys.argv[9] - - tmp_dir = tempfile.mkdtemp() - try: - assert os.path.exists( chrom_info_file ), "The required chromosome length file does not exist." - proc = subprocess.Popen( args="%s %s > %s" % ( CCAT_BINARY, " ".join( map( lambda x: "'%s'" % x, [ input_tag_file, input_control_file, chrom_info_file, input_config_file, project_name ] ) ), output_log_file ), shell=True, cwd=tmp_dir ) - proc.wait() - if proc.returncode: - raise Exception( "Error code: %i" % proc.returncode ) - output_num = get_top_count( input_config_file ) - shutil.move( os.path.join( tmp_dir, "%s.significant.peak" % project_name ), output_peak_file ) - shutil.move( os.path.join( tmp_dir, "%s.significant.region" % project_name ), output_region_file ) - shutil.move( os.path.join( tmp_dir, "%s.top%i.peak" % ( project_name, output_num ) ), output_top_file ) - except Exception, e: - return stop_err( tmp_dir, e ) - os.rmdir( tmp_dir ) #clean up empty temp working directory - -if __name__ == "__main__": main()