@@ -885,33 +885,33 @@ def Start(parser=None,
885885 choices = ("sam" , "bam" , "cram" ),
886886 default = None ,
887887 help = "File format of the input file. Format is usually" \
888- "implied from the extension of the filename, but" \
889- "maybe overridden with this option. Default=bam" )
888+ " implied from the extension of the filename, but" \
889+ " maybe overridden with this option. Default=bam" )
890890 group .add_option ("--out-format" , dest = "out_format" ,
891891 type = "choice" ,
892892 choices = ("sam" , "bam" , "cram" ),
893893 default = None ,
894894 help = "File format of the input file. Format is usually" \
895- "implied from the extension of the filename, but" \
896- "maybe overridden with this option. Default=bam" )
895+ " implied from the extension of the filename, but" \
896+ " maybe overridden with this option. Default=bam" )
897897 group .add_option ("--input-options" , dest = "input_options" , action = "store" ,
898898 type = "str" ,
899899 default = None ,
900900 help = "Format string provided to htslib for reading. Mostly" \
901- "useful for CRAM formatted files. See samtools documentation" )
901+ " useful for CRAM formatted files. See samtools documentation" )
902902 group .add_option ("--output-options" , dest = "output_options" , action = "store" ,
903903 type = "str" ,
904904 default = None ,
905905 help = "Format string provided to htslib for writing. Mostly" \
906- "useful for CRAM formatted files. See samtools documentation" )
906+ " useful for CRAM formatted files. See samtools documentation" )
907907 group .add_option ("--reference-filename" , dest = "reference_filename" ,
908908 action = "store" ,
909909 default = None ,
910910 help = "File path or URL to the genome reference to be used" \
911- "when reading or writing CRAM files. By default, when reading" \
912- "a CRAM file, the reference recorded in the input file will be" \
913- "used unless this is specified. When writing, specifying a" \
914- "reference location is required." )
911+ " when reading or writing CRAM files. By default, when reading" \
912+ " a CRAM file, the reference recorded in the input file will be" \
913+ " used unless this is specified. When writing, specifying a" \
914+ " reference location is required." )
915915 group .add_option ("--mapping-quality" , dest = "mapping_quality" ,
916916 type = "int" ,
917917 help = "Minimum mapping quality for a read to be retained"
@@ -1466,8 +1466,8 @@ def debug(message):
14661466def error (message ):
14671467 '''log error message, see the :mod:`logging` module'''
14681468 logging .error (message )
1469- raise ValueError ("UMI-tools failed with an error. Check the log file" )
1470-
1469+ sys . stderr . write ("UMI-tools failed with an error. Check the log file\n " )
1470+ sys . exit ( 1 )
14711471
14721472def critical (message ):
14731473 '''log critical message, see the :mod:`logging` module'''
@@ -1746,6 +1746,12 @@ def sort_output(sorted_out_name,
17461746 params .extend (["--output-fmt-options" , format_options ])
17471747
17481748 params .append (infile )
1749- debug (params )
1750- pysam .sort (* params )
1749+
1750+ try :
1751+ pysam .sort (* params )
1752+ except pysam .SamtoolsError as e :
1753+ error ("Sorting output file failed.\n \n Sort command was:\n " +
1754+ " " .join (params ) + "\n \n " +
1755+ f"Error was:\n { e .value } " )
1756+
17511757 os .unlink (infile ) # delete the tempfile
0 commit comments