#!usr/bin/env python import re from parameter.common_parameters import common_parameters import utils.setting_utils as utils utils.now_time("bed_3UTR script starting...") p = utils.Bunch(common_parameters) def main(): input_file = p.bed_3UTR_input output_file = p.bed_3UTR_output command_bed_3UTR = '../software/bed12to3UTRbed.sh ' + input_file + ' > ' + output_file print (command_bed_3UTR) utils.run_command(command_bed_3UTR) utils.now_time("bed_3UTR script was successfully finished!!") if __name__ == '__main__': main()
import yaml import itertools import shelve import utils.setting_utils as utils from parameter.common_parameters import common_parameters from parameter.mirna_seed_infor import mirna_seed_infor from module.analysis.seed_match import find_mirna_target_candidates from module.analysis.thermo_calc import calc_thermo from module.analysis.motif_occurrence import motif_occurrence from module.analysis.conservation_estimation import conservation_estimation from module.analysis.target_site_composition import target_site_composition #test from module.analysis.seed_match_rev import find_mirna_subtarget_candidates p = utils.Bunch(common_parameters) seed_infor = utils.Bunch(mirna_seed_infor) #print (seed_infor.seed_length) flg_find_mirna_target_candidates = 0 def progress_bar(per, counter, barlen=50): perb = int(per/(100.0/barlen)) s = '\r' s += '[' s += '*' * perb s += ' ' * (barlen - perb) s += ']' s += ' ' + (str(int(per)) + '%' + ' - ' + str(counter) + ' pairs').rjust(4) sys.stdout.write(s)
def main(): parser = argparse.ArgumentParser( prog="mirage_prepare", description="MIRAGE preparation toolkit - Data preparation for MIRAGE") parser.add_argument( 'preparation_type', action='store', choices=[ 'bed_3UTR', 'mirbase_gff2bed', 'liftOver', 'phylop_score_prep', 'phastcons_prep', 'phylop_sizedown', 'phastcons_sizedown', 'phylop_score_list', 'phastcons_score_list', 'phastcons_score_R', 'phylop_score_R', 'refseq_pre', 'mirbase_pre', 'mirmark_result', 'cupid_result' ], help= 'Preparation Type: refseq_pre|mirbase_pre|mirmark_result|cupid_result|' ) parser.add_argument( '-i', '--input-file', action='store', dest='input_file', help='Input file: Specify a input file name and its path') parser.add_argument( '-r', '--reference-file', action='store', dest='reference_file', help='reference file: Specify a reference file name and its path') parser.add_argument( '-a', '--additional-file', action='store', dest='add_file', nargs=3, help= 'Additional_file: Specify 1-refseq_pre file dir, 2-mirbase_pre file dir, 3-error log dir)' ) parser.add_argument( '-o', '--ouput-file', action='store', dest='output_file', help='Output file: Specify a output file name and its path') args = parser.parse_args() #Start analysis - logging greeting() utils.now_time('MIRAGE Data Preparation starting...') #Parameter preparation prep_type = args.preparation_type if (args.input_file or args.output_file): if not (os.path.isfile(args.input_file)): utils.now_time("ERROR: InputFile does not exist...") sys.exit(1) if not (args.output_file): utils.now_time("ERROR: -o option are required...") sys.exit(1) custom_params = {} if prep_type == 'bed_3UTR': custom_params['bed_3UTR_input'] = args.input_file custom_params['bed_3UTR_output'] = args.output_file common_parameters.updata(custom_params) p = utils.Bunch(common_parameters) elif prep_type == 'mirbase_gff2bed': custom_params['mirbase_gff2bed_input'] = args.input_file custom_params['mirbase_gff2bed_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) elif prep_type == 'liftOver': custom_params['liftover_input'] = args.input_file custom_params['liftover_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) elif prep_type == 'phylop_score_prep': custom_params['phylop_score_prep_input'] = args.input_file custom_params['phylop_score_prep_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) elif prep_type == 'phastcons_prep': custom_params['phastcons_prep_input'] = args.input_file custom_params['phastcons_prep_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) elif prep_type == 'phylop_sizedown': if args.reference_file: custom_params[ 'phylop_sizedown_bed_input'] = args.reference_file custom_params['phylop_sizedown_score_input'] = args.input_file custom_params[ 'phylop_sizedown_score_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) else: utils.now_time("ERROR: -r option is required...") sys.exit(1) elif prep_type == 'phastcons_sizedown': if args.reference_file: custom_params[ 'phastcons_sizedown_bed_input'] = args.reference_file custom_params[ 'phastcons_sizedown_score_input'] = args.input_file custom_params[ 'phastcons_sizedown_score_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) else: utils.now_time("ERROR: -r option is required...") sys.exit(1) elif prep_type == 'phylop_score_list': if args.reference_file: custom_params[ 'phylop_score_list_reference'] = args.reference_file custom_params['phylop_score_list_db_input'] = args.input_file custom_params['phylop_score_list_db_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) else: utils.now_time("ERROR: -r option is required...") sys.exit(1) elif prep_type == 'phastcons_score_list': if args.reference_file: custom_params[ 'phastcons_score_list_reference'] = args.reference_file custom_params[ 'phastcons_score_list_db_input'] = args.input_file custom_params[ 'phastcons_score_list_db_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) else: utils.now_time("ERROR: -r option is required...") sys.exit(1) elif prep_type == 'phastcons_score_R': custom_params['phastcons_score_R_input'] = args.input_file custom_params['phastcons_score_R_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) elif prep_type == 'phylop_score_R': custom_params['phylop_score_R_input'] = args.input_file custom_params['phylop_score_R_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) elif prep_type == 'refseq_pre': custom_params['refseq_pre_input'] = args.input_file custom_params['refseq_pre_output'] = args.output_file common_parameters.update(custom_params) p = utils.Bunch(common_parameters) elif prep_type == 'mirbase_pre': custom_params['mirbase_pre_input'] = args.input_file custom_params['mirbase_pre_output'] = args.output_file p = utils.Bunch(common_parameters) elif prep_type == 'mirmark_result': if args.add_file: custom_params['refseq_pre_output'] = args.add_file[0] custom_params['mirbase_pre_output'] = args.add_file[1] custom_params['mirmark_pos'] = args.input_file custom_params['mirmark_output'] = args.output_file custom_params['mirmark_error'] = args.add_file[2] p = utils.Bunch(common_parameters) else: utils.now_time("ERROR: -a option is required...") sys.exit(1) elif prep_type == 'cupid_result': if args.add_file: custom_params['refseq_pre_output'] = args.add_file[0] custom_params['mirbase_pre_output'] = args.add_file[1] custom_params['cupid_pos'] = args.input_file custom_params['cupid_output'] = args.output_file custom_params['cupid_error'] = args.add_file[2] p = utils.Bunch(common_parameters) else: utils.now_time("ERROR: -a option is required...") sys.exit(1) else: utils.now_time("ERROR: Wrong preparation type...") sys.exit(1) elif not (args.input_file and args.output_file): if prep_type: p = utils.Bunch(common_parameters) else: utils.now_time("ERROR: Wrong preparation type...") sys.exit(1) else: utils.now_time("ERROR: -i and -o option are required...") sys.exit(1) #Preparation type if prep_type == 'bed_3UTR': runpy.run_module('module.preparation.bed_3UTR', run_name="__main__", alter_sys=True) elif prep_type == 'mirbase_gff2bed': runpy.run_module('module.preparation.mirbase_gff2bed', run_name="__main__", alter_sys=True) elif prep_type == 'liftOver': runpy.run_module('module.preparation.liftOver', run_name="__main__", alter_sys=True) elif prep_type == 'phylop_score_prep': runpy.run_module('module.preparation.phylop_score_prep', run_name="__main__", alter_sys=True) elif prep_type == 'phastcons_prep': runpy.run_module('module.preparation.phastcons_score_prep', run_name="__main__", alter_sys=True) elif prep_type == 'phastcons_sizedown': runpy.run_module('module.preparation.phastcons_sizedown', run_name='__main__', alter_sys=True) elif prep_type == 'phylop_sizedown': runpy.run_module('module.preparation.phylop_sizedown', run_name="__main__", alter_sys=True) elif prep_type == 'phylop_score_list': runpy.run_module('module.preparation.phylop_score_list', run_name='__main__', alter_sys=True) elif prep_type == 'phastcons_score_list': runpy.run_module('module.preparation.phastcons_score_list', run_name='__main__', alter_sys=True) elif prep_type == 'phastcons_score_R': runpy.run_module('module.preparation.phastcons_score_R', run_name='__main__', alter_sys=True) elif prep_type == 'phylop_score_R': runpy.run_module('module.preparation.phylop_score_R', run_name='__main__', alter_sys=True) elif prep_type == 'refseq_pre': runpy.run_module('module.preparation.refseq_pre', run_name="__main__", alter_sys=True) elif prep_type == 'mirbase_pre': runpy.run_module('module.preparation.mirbase_pre', run_name="__main__", alter_sys=True) elif prep_type == 'mirmark_result': runpy.run_module('module.preparation.mirmark_result', run_name="__main__", alter_sys=True) elif prep_type == 'cupid_result': runpy.run_module('module.preparation.cupid_result', run_name="__main__", alter_sys=True) else: utils.now_time("ERROR: Wrong preparation type...") sys.exit(1)
def main(): parser = argparse.ArgumentParser( prog='mirage', description='MIRAGE - Comprehensive miRNA target prediction pipeline') parser.add_argument('analysis_type', action='store', help='Analysis_type: Choose estimation or prediction', choices=['estimation', 'prediction']) parser.add_argument( 'mirna_fasta', action='store', help='miRNA fasta file: Specify miRNA fasta file to use the analysis') parser.add_argument( 'targetrna_fasta', action='store', help= 'TargetRNA fasta file: Specify TargetRNA fasta file to use the analysis' ) parser.add_argument( '-m', '--mirna-conservation-score-file', action='store', dest='mirna_conservation', help= 'Conservation score file about miRNA: Specify your conservation score db file. MIRAGE preparetion toolkits enables you to make the score files about TargetRNA or miRNA bed files.' ) parser.add_argument( '-t', '--targetrna-conservation-score-file', action='store', dest='targetrna_conservation', help= 'Conservation score file about TargetRNA: Specify your conservation score db file. MIRAGE preparetion toolkits enables you to make the score files about TargetRNA or miRNA bed files.' ) args = parser.parse_args() #Start analysis - logging greeting() utils.now_time("MIRAGE miRNA target prediction starting...") analysis_type = args.analysis_type mirna_fasta_path = args.mirna_fasta targetrna_fasta_path = args.targetrna_fasta mirna_conservation_score = args.mirna_conservation targetrna_conservation_score = args.targetrna_conservation #Check fasta files if not os.path.isfile(mirna_fasta_path): print("Error: miRNA fasta file does not exist...") sys.exit(1) if not os.path.isfile(targetrna_fasta_path): print("Error: TargetRNA fasta file does not exist...") #Check conservation score db files #if #parameters param = dict( MIRNA_FASTA_PATH=mirna_fasta_path, TARGETRNA_FASTA_PATH=targetrna_fasta_path, ) common_parameters.update(param) p = utils.Bunch(common_parameters) print('miRNA_Fasta_file: ' + p.MIRNA_FASTA_PATH, end="\n") print('TargetRNA_Fasta_file: ' + p.TARGETRNA_FASTA_PATH, end="\n") ''' mirna_dict = utils.load_fasta(mirna_fasta_path) #print (mirna_dict['hsa-miR-34b-5p|MIMAT0000685'],end="\n") #print (mirna_dict['hsa-miR-20a-5p|MIMAT0000075'],end="\n") targetrna_dict = utils.load_fasta(targetrna_fasta_path) #print (targetrna_dict['NM_000594'],end="\n") #print (targetrna_dict['NM_030938'],end="\n") query_mirna.update(mirna_dict) print (query_mirna) mirna = utils.Bunch(query_mirna) query_targetrna.update(targetrna_dict) targetrna = utils.Bunch(query_targetrna) if hasattr (mirna,'hsa-miR-34b-5p|MIMAT0000685'): print ("OK!!") print (mirna.items()) sys.exit(0) else: print ("Error...") sys.exit(1) #test = targetrna.'NM_000594' #print (test,end="\n") #sys.exit(0) ''' #runpy - choose analysis type if analysis_type == 'estimation': runpy.run_module('module.estimate', run_name="__main__", alter_sys=True) elif analysis_type == 'prediction': runpy.run_module('module.predict', run_name="__main__", alter_sys=True) else: print('Error: Analysis type is wrong...') sys.exit(1)