<s> import os . path , re , mmap <EOL> from fabric . api import cd , env , hide , local , run , settings , sudo , task <EOL> from fabric . network import disconnect_all <EOL> dependency_URL = "<STR_LIT>" <EOL> galaxy_central = "<STR_LIT>" <EOL> galaxy_VCR_path = "<STR_LIT>" % galaxy_central <EOL> def install_galaxy_vcr ( env ) : <EOL> with cd ( "<STR_LIT>" ) : <EOL> print ( "<STR_LIT>" ) <EOL> sudo ( "<STR_LIT>" ) <EOL> sudo ( "<STR_LIT>" % galaxy_VCR_path ) <EOL> sudo ( "<STR_LIT>" % galaxy_VCR_path ) <EOL> with cd ( galaxy_central ) : <EOL> print ( "<STR_LIT>" ) <EOL> tcx_file = "<STR_LIT>" <EOL> _set_pre_VCR ( tcx_file , "<STR_LIT>" , "<STR_LIT>" ) <EOL> tcx_string = _get_file_string ( tcx_file , galaxy_central ) <EOL> vcr_header = "<STR_LIT>" <EOL> if ( tcx_string . find ( vcr_header ) != - <NUM_LIT:1> ) : <EOL> print ( "<STR_LIT>" ) <EOL> else : <EOL> sudo ( "<STR_LIT>" % ( galaxy_central , tcx_file ) ) <EOL> sudo ( "<STR_LIT>" % tcx_file ) <EOL> sudo ( "<STR_LIT>" % tcx_file ) <EOL> sudo ( "<STR_LIT>" % tcx_file ) <EOL> sudo ( "<STR_LIT>" % tcx_file ) <EOL> sudo ( "<STR_LIT>" % tcx_file ) <EOL> print ( "<STR_LIT>" ) <EOL> uwi_file = "<STR_LIT>" <EOL> _set_pre_VCR ( uwi_file , "<STR_LIT>" , "<STR_LIT>" ) <EOL> uwi_string = _get_file_string ( uwi_file , galaxy_central ) <EOL> if ( uwi_string . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) : <EOL> print ( "<STR_LIT>" % uwi_file ) <EOL> sudo ( "<STR_LIT>" % uwi_file ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> sudo ( "<STR_LIT>" % uwi_file ) <EOL> viral_dirs = { } <EOL> viral_urls = { } <EOL> viral_tars = { } <EOL> def install_viralassembly ( env ) : <EOL> try : <EOL> _initialize_area_viral ( ) <EOL> _add_tools_viral ( ) <EOL> _add_refs ( ) <EOL> sudo ( "<STR_LIT>" % env ) <EOL> finally : <EOL> disconnect_all ( ) <EOL> def install_viralassembly_cleanall ( env ) : <EOL> try : <EOL> _initialize_env ( "<STR_LIT>" ) <EOL> _remove_dir ( "<STR_LIT>" % env ) <EOL> print ( "<STR_LIT>" ) <EOL> finally : <EOL> disconnect_all ( ) <EOL> def _initialize_area_viral ( ) : <EOL> _initialize_env ( "<STR_LIT>" ) <EOL> env . VIRAL_SCRIPT = "<STR_LIT>" % dependency_URL <EOL> viral_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % env <EOL> viral_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % env <EOL> viral_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % env <EOL> viral_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % viral_dirs [ "<STR_LIT>" ] <EOL> viral_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % viral_dirs [ "<STR_LIT>" ] <EOL> env . VIRAL_REF_FILES = "<STR_LIT>" <EOL> viral_urls [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> viral_tars [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> viral_tars [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> print ( "<STR_LIT>" % env ) <EOL> print ( "<STR_LIT>" % env ) <EOL> print ( "<STR_LIT>" % env ) <EOL> print ( "<STR_LIT>" % env ) <EOL> for name in sorted ( viral_dirs . keys ( ) ) : <EOL> if not _path_is_dir ( viral_dirs [ name ] ) : <EOL> sudo ( "<STR_LIT>" % viral_dirs [ name ] ) <EOL> print ( "<STR_LIT>" % ( name , viral_dirs [ name ] ) ) <EOL> print ( "<STR_LIT>" % env ) <EOL> for name in sorted ( viral_urls . keys ( ) ) : <EOL> print ( "<STR_LIT>" % ( name , viral_urls [ name ] ) ) <EOL> for name in sorted ( viral_tars . keys ( ) ) : <EOL> print ( "<STR_LIT>" % ( name , viral_tars [ name ] ) ) <EOL> def _add_tools_viral ( ) : <EOL> with cd ( "<STR_LIT>" ) : <EOL> bashrc_file = "<STR_LIT>" <EOL> _set_pre_VCR ( bashrc_file , "<STR_LIT>" , "<STR_LIT>" ) <EOL> bashrc_string = _get_file_string ( bashrc_file , "<STR_LIT>" ) <EOL> if ( bashrc_string . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) : <EOL> print ( "<STR_LIT>" % bashrc_file ) <EOL> sudo ( "<STR_LIT>" % ( "<STR_LIT>" , bashrc_file ) ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> sudo ( "<STR_LIT>" % bashrc_file ) <EOL> sudo ( "<STR_LIT>" % ( env . VIRAL_ROOT_DIR , env . VIRAL_SCRIPT ) ) <EOL> _add_package ( dependency_URL , viral_tars [ "<STR_LIT>" ] , viral_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> _add_package ( dependency_URL , viral_tars [ "<STR_LIT>" ] , viral_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> _initialize_bio_linux ( ) <EOL> def _add_refs ( ) : <EOL> files = ( env . VIRAL_REF_FILES ) . split ( "<STR_LIT:U+002C>" ) <EOL> for file in files : <EOL> _add_package ( dependency_URL , "<STR_LIT>" % file , viral_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> def _initialize_bio_linux ( ) : <EOL> sudo ( "<STR_LIT>" % viral_urls [ "<STR_LIT>" ] ) <EOL> sudo ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> vigor_dirs = { } <EOL> vigor_urls = { } <EOL> vigor_tars = { } <EOL> vigor_names = { } <EOL> def install_viralvigor ( env ) : <EOL> try : <EOL> _initialize_area_vigor ( ) <EOL> _initialize_host ( ) <EOL> _add_vigor ( ) <EOL> _add_tools_vigor ( ) <EOL> finally : <EOL> disconnect_all ( ) <EOL> def install_viralvigor_test ( env ) : <EOL> try : <EOL> _initialize_area_vigor ( ) <EOL> cmd = ( """<STR_LIT>""" ) % ( vigor_dirs [ "<STR_LIT>" ] , vigor_dirs [ "<STR_LIT>" ] , vigor_dirs [ "<STR_LIT>" ] , env . VIGOR_SCRATCH_DIR ) <EOL> print ( "<STR_LIT>" % cmd ) <EOL> run ( cmd ) <EOL> finally : <EOL> disconnect_all ( ) <EOL> def install_viralvigor_validate ( env ) : <EOL> try : <EOL> _initialize_area_vigor ( ) <EOL> sudo ( "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] ) <EOL> sudo ( "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] ) <EOL> with settings ( hide ( "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> results = run ( """<STR_LIT>""" % ( vigor_dirs [ "<STR_LIT>" ] , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> if results : <EOL> print ( "<STR_LIT>" % results ) <EOL> finally : <EOL> disconnect_all ( ) <EOL> def install_viralvigor_cleanall ( env ) : <EOL> try : <EOL> _initialize_env ( "<STR_LIT>" ) <EOL> _remove_dir ( env . VIGOR_ROOT_DIR ) <EOL> _remove_dir ( env . VIGOR_SCRATCH_DIR ) <EOL> print ( "<STR_LIT>" ) <EOL> finally : <EOL> disconnect_all ( ) <EOL> def _initialize_area_vigor ( ) : <EOL> machine = run ( "<STR_LIT>" ) <EOL> if machine . find ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> env . ARCH = '<STR_LIT>' <EOL> else : <EOL> env . ARCH = '<STR_LIT>' <EOL> _initialize_env ( "<STR_LIT>" ) <EOL> vigor_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % env . VIGOR_ROOT_DIR <EOL> vigor_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] <EOL> vigor_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] <EOL> vigor_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % env . VIGOR_SCRATCH_DIR <EOL> vigor_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] <EOL> vigor_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] <EOL> vigor_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] <EOL> vigor_dirs [ "<STR_LIT>" ] = "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] <EOL> vigor_dirs [ "<STR_LIT>" ] = vigor_dirs [ "<STR_LIT>" ] <EOL> vigor_names [ "<STR_LIT>" ] = '<STR_LIT>' <EOL> vigor_names [ "<STR_LIT>" ] = '<STR_LIT>' <EOL> vigor_names [ "<STR_LIT>" ] = '<STR_LIT>' <EOL> vigor_tars [ "<STR_LIT>" ] = "<STR_LIT>" % vigor_names [ "<STR_LIT>" ] <EOL> vigor_tars [ "<STR_LIT>" ] = "<STR_LIT>" % ( vigor_names [ "<STR_LIT>" ] , env . ARCH ) <EOL> vigor_tars [ "<STR_LIT>" ] = "<STR_LIT>" % ( vigor_names [ "<STR_LIT>" ] , env . ARCH ) <EOL> print ( "<STR_LIT>" % env ) <EOL> print ( "<STR_LIT>" % env ) <EOL> print ( "<STR_LIT>" % env ) <EOL> print ( "<STR_LIT>" % env ) <EOL> print ( "<STR_LIT>" % env ) <EOL> for name in sorted ( vigor_dirs . keys ( ) ) : <EOL> print ( "<STR_LIT>" % ( name , vigor_dirs [ name ] ) ) <EOL> for name in sorted ( vigor_urls . keys ( ) ) : <EOL> print ( "<STR_LIT>" % ( name , vigor_urls [ name ] ) ) <EOL> print ( "<STR_LIT>" % vigor_names [ "<STR_LIT>" ] ) <EOL> print ( "<STR_LIT>" % vigor_names [ "<STR_LIT>" ] ) <EOL> print ( "<STR_LIT>" % vigor_names [ "<STR_LIT>" ] ) <EOL> for name in sorted ( vigor_tars . keys ( ) ) : <EOL> print ( "<STR_LIT>" % ( name , vigor_tars [ name ] ) ) <EOL> def _initialize_host ( ) : <EOL> local ( "<STR_LIT>" % env ) <EOL> _fix_etc_hosts ( ) <EOL> _create_vigor_scratch_dir ( ) <EOL> def _add_vigor ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> _create_vigor_tempspace_dir ( ) <EOL> _create_vigor_scratch_dir ( ) <EOL> _add_package ( dependency_URL , vigor_tars [ "<STR_LIT>" ] , vigor_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> sudo ( "<STR_LIT>" % os . path . join ( vigor_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> if not _path_exists ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) ) : <EOL> sudo ( "<STR_LIT>" % ( "<STR_LIT>" , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> sudo ( "<STR_LIT>" % ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> if not _path_exists ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) ) : <EOL> sudo ( "<STR_LIT>" % ( vigor_dirs [ "<STR_LIT>" ] , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> def _add_tools_vigor ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> _create_tools_dir ( ) <EOL> _add_blast ( ) <EOL> _add_clustalw ( ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> def _fix_etc_hosts ( ) : <EOL> internal_ip = sudo ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" % internal_ip ) <EOL> filespec = "<STR_LIT>" <EOL> sudo ( "<STR_LIT>" % ( internal_ip , filespec ) ) <EOL> def _create_vigor_tempspace_dir ( ) : <EOL> if not _path_is_dir ( vigor_dirs [ "<STR_LIT>" ] ) : <EOL> sudo ( "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] ) <EOL> sudo ( "<STR_LIT>" % ( env . user , env . user , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> sudo ( "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] ) <EOL> def _create_vigor_scratch_dir ( ) : <EOL> if not _path_is_dir ( env . VIGOR_SCRATCH_DIR ) : <EOL> sudo ( "<STR_LIT>" % env . VIGOR_SCRATCH_DIR ) <EOL> sudo ( "<STR_LIT>" % env . VIGOR_SCRATCH_DIR ) <EOL> sudo ( "<STR_LIT>" % env . VIGOR_SCRATCH_DIR ) <EOL> def _create_tools_dir ( ) : <EOL> if not _path_is_dir ( vigor_dirs [ "<STR_LIT>" ] ) : <EOL> sudo ( "<STR_LIT>" % vigor_dirs [ "<STR_LIT>" ] ) <EOL> sudo ( "<STR_LIT>" % ( env . user , env . user , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> def _add_blast ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> _create_tools_dir ( ) <EOL> _add_package ( dependency_URL , vigor_tars [ "<STR_LIT>" ] , vigor_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> if not _path_exists ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) ) : <EOL> sudo ( "<STR_LIT>" % ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , vigor_names [ "<STR_LIT>" ] , "<STR_LIT>" , "<STR_LIT>" ) , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> sudo ( "<STR_LIT>" % ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , vigor_names [ "<STR_LIT>" ] , "<STR_LIT>" , "<STR_LIT>" ) , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> sudo ( "<STR_LIT>" % ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , vigor_names [ "<STR_LIT>" ] , "<STR_LIT>" , "<STR_LIT>" ) , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> sudo ( "<STR_LIT>" % ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , vigor_names [ "<STR_LIT>" ] , "<STR_LIT>" , "<STR_LIT>" ) , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> def _add_clustalw ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> _create_tools_dir ( ) <EOL> _add_package ( dependency_URL , vigor_tars [ "<STR_LIT>" ] , vigor_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> if not _path_exists ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , "<STR_LIT>" ) ) : <EOL> sudo ( "<STR_LIT>" % ( os . path . join ( vigor_dirs [ "<STR_LIT>" ] , vigor_names [ "<STR_LIT>" ] , "<STR_LIT>" ) , vigor_dirs [ "<STR_LIT>" ] ) ) <EOL> def install_vicvb ( env ) : <EOL> try : <EOL> _initialize_env ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> _apt_get_install ( "<STR_LIT>" ) <EOL> tbl2asn_download_dir = "<STR_LIT>" <EOL> tbl2asn_dir = "<STR_LIT>" <EOL> if _path_exists ( os . path . join ( tbl2asn_dir , "<STR_LIT>" ) ) : <EOL> sudo ( "<STR_LIT>" % ( tbl2asn_dir , tbl2asn_dir ) ) <EOL> _add_package ( "<STR_LIT>" , "<STR_LIT>" , tbl2asn_download_dir , "<STR_LIT>" ) <EOL> sudo ( "<STR_LIT>" % tbl2asn_download_dir ) <EOL> sudo ( "<STR_LIT>" % ( tbl2asn_download_dir , tbl2asn_dir ) ) <EOL> _remove_dir ( tbl2asn_download_dir ) <EOL> with cd ( "<STR_LIT>" ) : <EOL> sudo ( "<STR_LIT>" ) <EOL> with cd ( "<STR_LIT>" ) : <EOL> sudo ( "<STR_LIT>" % ( env . VICVB_LOCAL_DIR ) ) <EOL> finally : <EOL> disconnect_all ( ) <EOL> def install_vicvb_cleanall ( env ) : <EOL> try : <EOL> _initialize_env ( "<STR_LIT>" ) <EOL> _remove_dir ( env . VICVB_LOCAL_DIR ) <EOL> _remove_dir ( env . VICVB_GALAXY_DIR ) <EOL> with cd ( "<STR_LIT>" ) : <EOL> sudo ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> finally : <EOL> disconnect_all ( ) <EOL> def _initialize_env ( pipeline ) : <EOL> if pipeline == "<STR_LIT>" : <EOL> env . VIRAL_ROOT_DIR = "<STR_LIT>" <EOL> if not _path_exists ( env . VIRAL_ROOT_DIR ) : <EOL> sudo ( "<STR_LIT>" % env . VIRAL_ROOT_DIR ) <EOL> elif pipeline == "<STR_LIT>" : <EOL> env . VIGOR_ROOT_DIR = "<STR_LIT>" <EOL> if not _path_exists ( env . VIGOR_ROOT_DIR ) : <EOL> sudo ( "<STR_LIT>" % env . VIGOR_ROOT_DIR ) <EOL> env . VIGOR_SCRATCH_DIR = "<STR_LIT>" <EOL> if not _path_exists ( env . VIGOR_SCRATCH_DIR ) : <EOL> sudo ( "<STR_LIT>" % env . VIGOR_SCRATCH_DIR ) <EOL> sudo ( "<STR_LIT>" % env . VIGOR_SCRATCH_DIR ) <EOL> sudo ( "<STR_LIT>" % env . VIGOR_SCRATCH_DIR ) <EOL> else : <EOL> env . VICVB_LOCAL_DIR = "<STR_LIT>" ; <EOL> env . VICVB_GALAXY_DIR = "<STR_LIT>" ; <EOL> def _add_package ( download_url , filename , install_dir , type ) : <EOL> if not _path_is_dir ( install_dir ) : <EOL> sudo ( "<STR_LIT>" % install_dir ) <EOL> with cd ( install_dir ) : <EOL> if not _path_exists ( os . path . join ( install_dir , filename ) ) : <EOL> sudo ( """<STR_LIT>""" % ( install_dir , download_url , filename ) ) <EOL> if type == "<STR_LIT>" : <EOL> sudo ( "<STR_LIT>" % filename ) <EOL> elif type == "<STR_LIT>" : <EOL> sudo ( "<STR_LIT>" % filename ) <EOL> elif type == "<STR_LIT>" : <EOL> sudo ( "<STR_LIT>" % filename ) <EOL> else : <EOL> sudo ( "<STR_LIT>" % ( filename , install_dir ) ) <EOL> sudo ( "<STR_LIT>" % ( install_dir , vigor_names [ "<STR_LIT>" ] ) ) <EOL> sudo ( "<STR_LIT>" % ( install_dir , install_dir , vigor_names [ "<STR_LIT>" ] ) ) <EOL> sudo ( "<STR_LIT>" % ( env . user , env . user , install_dir ) ) <EOL> sudo ( "<STR_LIT>" % install_dir ) <EOL> def _remove_dir ( dirspec ) : <EOL> if _path_is_dir ( dirspec ) : <EOL> _unlock_dir ( dirspec ) <EOL> sudo ( "<STR_LIT>" % dirspec ) <EOL> else : <EOL> print ( "<STR_LIT>" % dirspec ) <EOL> def _unlock_dir ( dirspec ) : <EOL> with settings ( hide ( "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> sudo ( "<STR_LIT>" % dirspec ) <EOL> sudo ( "<STR_LIT>" % dirspec ) <EOL> sudo ( "<STR_LIT>" % dirspec ) <EOL> def _apt_get_install ( tool ) : <EOL> sudo ( "<STR_LIT>" % tool ) <EOL> def _path_exists ( path ) : <EOL> found = False <EOL> with settings ( hide ( "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> result = sudo ( "<STR_LIT>" % path ) <EOL> if result != "<STR_LIT>" : found = True <EOL> return found <EOL> def _path_is_dir ( path ) : <EOL> found = False <EOL> with settings ( hide ( "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> result = sudo ( "<STR_LIT>" % path ) <EOL> if result != "<STR_LIT>" : found = True <EOL> return found <EOL> def _set_pre_VCR ( filename , user , group ) : <EOL> sudo ( "<STR_LIT>" % ( filename , filename ) ) <EOL> sudo ( "<STR_LIT>" % ( user , group , filename ) ) <EOL> def _get_file_string ( filename , directory ) : <EOL> fh = open ( "<STR_LIT>" % ( directory , filename ) ) <EOL> string = mmap . mmap ( fh . fileno ( ) , <NUM_LIT:0> , access = mmap . ACCESS_READ ) <EOL> fh . close ( ) <EOL> return string </s>
