def main(command_line_args=None): """ :param command_line_args: """ VersionDependencies.python_check() if not command_line_args: command_line_args = sys.argv parser = argparse.ArgumentParser( description="A package to process Synthetic Lethal Data.\n {0} v{1}". format(__package__, __version__), formatter_class=RawTextHelpFormatter) parser.add_argument('--options_file', action='store', dest='options_file', required=True, help='File containing program parameters.') # Convert universal variables intended as boolean from string to boolean. args, options_parser = string_to_boolean(Tool_Box.options_file(parser)) # Check file names and paths for errors error_checking(args) log = Tool_Box.Logger(args) Tool_Box.log_environment_info(log, args, command_line_args) start_time = time.time() module_name = "Synthetic_Lethal" log.info( "{0} v{1}; Module: Synthetic Lethal Analysis v{2} Beginning".format( __package__, __version__, Synthetic_Lethal.__version__)) synthetic_lethal = Synthetic_Lethal.SyntheticLethal(log, args) if args.TargetSearch: synthetic_lethal.fastq_analysis() elif args.Statistics: synthetic_lethal.statistics() else: log.error('No module selected to run.') warning = "\033[1;31m **See warnings above**\033[m" if log.warning_occurred else '' elapsed_time = int(time.time() - start_time) log.info( "****Völundr {0} complete ({1} seconds, {2} Mb peak memory).****\n{3}". format(module_name, elapsed_time, Tool_Box.peak_memory(), warning))
def string_to_boolean(parser): """ Converts strings to boolean. Done to keep the eval() function out of the code. :param parser: :return: """ options_parser = Tool_Box.options_file(parser) args = options_parser.parse_args() options_parser.set_defaults(PairedEnd=bool(strtobool(args.PairedEnd))) options_parser.set_defaults(Build_PhiX_DataFrame=bool(strtobool(args.Build_PhiX_DataFrame))) args = options_parser.parse_args() return args, options_parser
def main(command_line_args=None): VersionDependencies.python_check() if not command_line_args: command_line_args = sys.argv run_start = datetime.datetime.today().strftime("%a %b %d %H:%M:%S %Y") parser = argparse.ArgumentParser(description="A little ditty to manipulate FASTQ files.\n {0} v{1}" .format(__package__, __version__), formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--options_file', action='store', dest='options_file', required=True, help='File containing program parameters.') options_parser = Tool_Box.options_file(parser) args = options_parser.parse_args() # args, options_parser = string_to_boolean(args, options_parser) options_parser.set_defaults(Trim5=0) options_parser.set_defaults(Trim3=0) options_parser.set_defaults(Minimum_Length=100) options_parser.set_defaults(N_Limit=100) options_parser.set_defaults(HaloPLEX=False) options_parser.set_defaults(ThruPLEX=False) options_parser.set_defaults(FASTQ_PreProcess=True) args = options_parser.parse_args() # Check options file for errors. error_checking(args) log = Tool_Box.Logger(args) Tool_Box.log_environment_info(log, args, command_line_args) start_time = time.time() module_name = "" # Initialize generator to read each FASTQ file fastq1 = FASTQ_Tools.FASTQ_Reader(args.FASTQ1, log) fastq2 = FASTQ_Tools.FASTQ_Reader(args.FASTQ2, log) index1 = FASTQ_Tools.FASTQ_Reader(args.Index1, log) index2 = FASTQ_Tools.FASTQ_Reader(args.Index2, log) splitter_data = FASTQ_Tools.FastqSplitter(args, log, fastq1, fastq2, index1, index2, paired_end=True) new_fastq1, new_fastq2 = splitter_data.file_writer() warning = "\033[1;31m **See warnings above**\033[m" if log.warning_occurred else '' elapsed_time = int(time.time() - start_time) log.info("****FASTQ Preprocessing {0} complete ({1} seconds, {2} Mb peak memory).****" .format(module_name, elapsed_time, Tool_Box.peak_memory(), warning))
def string_to_boolean(parser): """ Converts strings to boolean. Done to keep the eval() function out of the code. :param parser: :return: """ options_parser = Tool_Box.options_file(parser) args = options_parser.parse_args() if args.IndelProcessing == "True": # Tool_Box.debug_messenger("Pear set to FALSE.") options_parser.set_defaults(PEAR=True) options_parser.set_defaults( Demultiplex=bool(strtobool(args.Demultiplex))) options_parser.set_defaults( OutputRawData=bool(strtobool(args.OutputRawData))) options_parser.set_defaults( DeleteConsensusFASTQ=bool(strtobool(args.DeleteConsensusFASTQ))) options_parser.set_defaults( IndelProcessing=bool(strtobool(args.IndelProcessing))) options_parser.set_defaults(Verbose=args.Verbose.upper()) return options_parser.parse_args()
def main(command_line_args=None): """ :param command_line_args: """ VersionDependencies.python_check() if not command_line_args: command_line_args = sys.argv parser = argparse.ArgumentParser( description="A package to process Synthetic Lethal Data.\n {0} v{1}". format(__package__, __version__), formatter_class=RawTextHelpFormatter) parser.add_argument('--options_file', action='store', dest='options_file', required=True, help='File containing program parameters.') options_parser = Tool_Box.options_file(parser) args = options_parser.parse_args() # If we are doing statistical analysis the user will not input an Index_Mismatch value if not getattr(args, "Index_Mismatch", False): options_parser.add_argument("--Index_Mismatch", dest="Index_Mismatch", default=0) options_parser.add_argument("--Analyze_Unknowns", dest="Analyze_Unknowns", default="False") args = options_parser.parse_args() log = Tool_Box.Logger(args) Tool_Box.log_environment_info(log, args, command_line_args) start_time = time.time() module_name = "Synthetic_Lethal" log.info( "{0} v{1}; Module: Synthetic Lethal Analysis v{2} Beginning".format( __package__, __version__, Synthetic_Lethal.__version__)) # Convert universal variables intended as boolean from string to boolean. # ToDo: Should be a cleaner method to do this. if args.Target_Search == "True": options_parser.set_defaults(Target_Search=True) if args.RevComp == "True": options_parser.set_defaults(RevComp=True) else: options_parser.set_defaults(RevComp=False) if args.Delete_Demultiplexed_FASTQ == "True": options_parser.set_defaults(Delete_Demultiplexed_FASTQ=True) else: options_parser.set_defaults(Delete_Demultiplexed_FASTQ=False) if args.compress == "True": options_parser.set_defaults(compress=True) else: options_parser.set_defaults(compress=False) else: options_parser.set_defaults(Target_Search=False) if args.Statistics == "True": options_parser.set_defaults(Statistics=True) else: options_parser.set_defaults(Statistics=False) if args.Analyze_Unknowns == "True": options_parser.set_defaults(Analyze_Unknowns=True) else: options_parser.set_defaults(Analyze_Unknowns=False) args = options_parser.parse_args() synthetic_lethal = Synthetic_Lethal.SyntheticLethal(log, args) # Add some parameters to our options parser object. args = options_parser.parse_args() if args.Target_Search: synthetic_lethal.fastq_analysis() elif args.Statistics: synthetic_lethal.statistics() else: log.error('No module selected to run.') warning = "\033[1;31m **See warnings above**\033[m" if log.warning_occurred else '' elapsed_time = int(time.time() - start_time) log.info( "****Volundr {0} complete ({1} seconds, {2} Mb peak memory).****\n{3}". format(module_name, elapsed_time, Tool_Box.peak_memory(), warning))
def string_conversions(parser): """ Convert True/False statements in parameter file to boolean :param parser: :return: """ options_parser = Tool_Box.options_file(parser) initial_args = options_parser.parse_args() options_parser.set_defaults( TargetSearch=bool(strtobool(initial_args.TargetSearch))) options_parser.set_defaults( Statistics=bool(strtobool(initial_args.Statistics))) options_parser.set_defaults(Verbose=initial_args.Verbose.upper()) if initial_args.Statistics == "False": options_parser.set_defaults( AnchorSeq=initial_args.AnchorSeq.upper()) options_parser.set_defaults(Analyze_Unknowns=bool( strtobool(initial_args.Analyze_Unknowns))) options_parser.set_defaults(Delete_Demultiplexed_FASTQ=bool( strtobool(initial_args.Delete_Demultiplexed_FASTQ))) options_parser.set_defaults( RevComp=bool(strtobool(initial_args.RevComp))) options_parser.set_defaults(BatchSize=int(initial_args.BatchSize)) options_parser.set_defaults( Target_Mismatch=int(initial_args.Target_Mismatch)) options_parser.set_defaults( MinimumReadLength=int(initial_args.MinimumReadLength)) options_parser.set_defaults(N_Limit=10) options_parser.set_defaults( Target_Length=int(initial_args.Target_Length)) options_parser.set_defaults( Target_Start=int(initial_args.Target_Start)) # options_parser.set_defaults(Index_Mismatch=int(initial_args.Index_Mismatch)) options_parser.set_defaults(Spawn=int(initial_args.Spawn)) options_parser.set_defaults( Target_Padding=int(initial_args.Target_Padding)) options_parser.set_defaults( Expected_Position=int(initial_args.Expected_Position)) options_parser.set_defaults( AnchorMismatch=int(initial_args.AnchorMismatch)) options_parser.set_defaults( AnchorStart=int(initial_args.AnchorStart)) options_parser.set_defaults( AnchorStop=int(initial_args.AnchorStop)) else: options_parser.set_defaults( Write_TDnorm_Log2_sgRNA_Control_File=bool( strtobool( initial_args.Write_TDnorm_Log2_sgRNA_Control_File))) options_parser.set_defaults( Write_TDnorm_Log2_sgRNA_Sample_File=bool( strtobool( initial_args.Write_TDnorm_Log2_sgRNA_Sample_File))) options_parser.set_defaults(Write_Log2_sgRNA_File=bool( strtobool(initial_args.Write_Log2_sgRNA_File))) options_parser.set_defaults(Write_Permuted_Log2_Data_File=bool( strtobool(initial_args.Write_Permuted_Log2_Data_File))) options_parser.set_defaults(Bad_sgRNA_Lower_Percentile=float( initial_args.Bad_sgRNA_Lower_Percentile)) options_parser.set_defaults(Bad_sgRNA_Upper_Percentile=float( initial_args.Bad_sgRNA_Upper_Percentile)) options_parser.set_defaults( UpperPercentile=float(initial_args.UpperPercentile)) options_parser.set_defaults( LowerPercentile=float(initial_args.LowerPercentile)) options_parser.set_defaults( PermutationCount=int(initial_args.PermutationCount)) options_parser.set_defaults(Alpha=float(initial_args.Alpha)) options_parser.set_defaults( Target_Mismatch=float(initial_args.Target_Mismatch)) options_parser.set_defaults( UpperGuideLimit=float(initial_args.UpperGuideLimit)) options_parser.set_defaults( LowerGuideLimit=float(initial_args.LowerGuideLimit)) initial_args = options_parser.parse_args() return initial_args
plot_data_dict[data_pair[6]][5].append(data_pair[4]) plot_data_dict[data_pair[6]][6].append(data_pair[5]) plot_data_dict[data_pair[6]][7].append(color_dict[data_pair[6]]) count = len(plot_data_dict[data_pair[6]][0]) if count > 1: previous = plot_data_dict[data_pair[6]][0][count - 2] plot_data_dict[data_pair[6]][8]\ .append(plot_data_dict[data_pair[6]][8][count - 2] + 0.0007 + (0.5*previous) + data_pair[0] * 0.5) return plot_data_dict # This is here to run the module as a stand-alone. if __name__ == '__main__': ToolBox.debug_messenger("Standing Alone") parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--options_file', action='store', dest='options_file', required=True, help='File containing program parameters.') options_parser = ToolBox.options_file(parser) args = options_parser.parse_args() scarmapperplot(args)