nodes: 0, module; 1, function_definition; 2, function_name:sortmerna_map; 3, parameters; 4, block; 5, identifier:seq_path; 6, identifier:output_dir; 7, identifier:refseqs_fp; 8, identifier:sortmerna_db; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_parameter; 16, default_parameter; 17, default_parameter; 18, expression_statement; 19, if_statement; 20, if_statement; 21, comment:# Instantiate the object; 22, expression_statement; 23, comment:# Set the input reference sequence + indexed database path; 24, expression_statement; 25, comment:# Set input query sequences path; 26, expression_statement; 27, comment:# Set Blast tabular output; 28, comment:# The option --blast 3 represents an; 29, comment:# m8 blast tabular output + two extra; 30, comment:# columns containing the CIGAR string; 31, comment:# and the query coverage; 32, if_statement; 33, comment:# Output alignments in SAM format; 34, if_statement; 35, comment:# Turn on NULL string alignment output; 36, if_statement; 37, comment:# Set output results path (for Blast alignments and log file); 38, expression_statement; 39, expression_statement; 40, comment:# Set E-value threshold; 41, if_statement; 42, comment:# Set number of best alignments to output per read; 43, if_statement; 44, comment:# Set number of first alignments passing E-value threshold; 45, comment:# to output per read; 46, if_statement; 47, comment:# Set number of threads; 48, if_statement; 49, comment:# Turn off parameters related to OTU-picking; 50, expression_statement; 51, expression_statement; 52, expression_statement; 53, expression_statement; 54, expression_statement; 55, comment:# Run sortmerna; 56, expression_statement; 57, return_statement; 58, identifier:e_value; 59, integer:1; 60, identifier:threads; 61, integer:1; 62, identifier:best; 63, None; 64, identifier:num_alignments; 65, None; 66, identifier:HALT_EXEC; 67, False; 68, identifier:output_sam; 69, False; 70, identifier:sam_SQ_tags; 71, False; 72, identifier:blast_format; 73, integer:3; 74, identifier:print_all_reads; 75, True; 76, comment:"""Launch sortmerna mapper
  
          Parameters
          ----------
          seq_path : str
              filepath to reads.
          output_dir : str
              dirpath to sortmerna output.
          refseqs_fp : str
              filepath of reference sequences.
          sortmerna_db : str
              indexed reference database.
          e_value : float, optional
              E-value threshold [default: 1].
          threads : int, optional
              number of threads to use (OpenMP) [default: 1].
          best : int, optional
              number of best alignments to output per read
              [default: None].
          num_alignments : int, optional
              number of first alignments passing E-value threshold to
              output per read [default: None].
          HALT_EXEC : bool, debugging parameter
              If passed, will exit just before the sortmerna command
              is issued and will print out the command that would
              have been called to stdout [default: False].
          output_sam : bool, optional
              flag to set SAM output format [default: False].
          sam_SQ_tags : bool, optional
              add SQ field to SAM output (if output_SAM is True)
              [default: False].
          blast_format : int, optional
              Output Blast m8 tabular + 2 extra columns for CIGAR
              string and query coverge [default: 3].
          print_all_reads : bool, optional
              output NULL alignments for non-aligned reads
              [default: True].
  
          Returns
          -------
          dict of result paths set in _get_result_paths()
      """; 77, not_operator; 78, block; 79, parenthesized_expression; 80, block; 81, assignment; 82, call; 83, call; 84, identifier:blast_format; 85, block; 86, identifier:output_sam; 87, block; 88, identifier:print_all_reads; 89, block; 90, assignment; 91, call; 92, comparison_operator:e_value is not None; 93, block; 94, comparison_operator:best is not None; 95, block; 96, comparison_operator:num_alignments is not None; 97, block; 98, comparison_operator:threads is not None; 99, block; 100, call; 101, call; 102, call; 103, call; 104, call; 105, assignment; 106, identifier:app_result; 107, parenthesized_expression; 108, raise_statement; 109, boolean_operator; 110, raise_statement; 111, identifier:smr; 112, call; 113, attribute; 114, argument_list; 115, attribute; 116, argument_list; 117, expression_statement; 118, expression_statement; 119, if_statement; 120, expression_statement; 121, identifier:output_file; 122, call; 123, attribute; 124, argument_list; 125, identifier:e_value; 126, None; 127, expression_statement; 128, identifier:best; 129, None; 130, expression_statement; 131, identifier:num_alignments; 132, None; 133, expression_statement; 134, identifier:threads; 135, None; 136, expression_statement; 137, attribute; 138, argument_list; 139, attribute; 140, argument_list; 141, attribute; 142, argument_list; 143, attribute; 144, argument_list; 145, attribute; 146, argument_list; 147, identifier:app_result; 148, call; 149, boolean_operator; 150, call; 151, identifier:best; 152, identifier:num_alignments; 153, call; 154, identifier:Sortmerna; 155, argument_list; 156, subscript; 157, identifier:on; 158, binary_operator:"%s,%s" % (refseqs_fp, sortmerna_db); 159, subscript; 160, identifier:on; 161, identifier:seq_path; 162, call; 163, call; 164, identifier:sam_SQ_tags; 165, block; 166, call; 167, identifier:join; 168, argument_list; 169, subscript; 170, identifier:on; 171, identifier:output_file; 172, call; 173, call; 174, call; 175, call; 176, subscript; 177, identifier:off; 178, subscript; 179, identifier:off; 180, subscript; 181, identifier:off; 182, subscript; 183, identifier:off; 184, subscript; 185, identifier:off; 186, identifier:smr; 187, argument_list; 188, identifier:blast_format; 189, identifier:output_sam; 190, identifier:ValueError; 191, argument_list; 192, identifier:ValueError; 193, argument_list; 194, keyword_argument; 195, attribute; 196, string; 197, string:"%s,%s"; 198, tuple; 199, attribute; 200, string; 201, attribute; 202, argument_list; 203, attribute; 204, argument_list; 205, expression_statement; 206, attribute; 207, argument_list; 208, identifier:output_dir; 209, string:"sortmerna_map"; 210, attribute; 211, string; 212, attribute; 213, argument_list; 214, attribute; 215, argument_list; 216, attribute; 217, argument_list; 218, attribute; 219, argument_list; 220, attribute; 221, string; 222, attribute; 223, string; 224, attribute; 225, string; 226, attribute; 227, string; 228, attribute; 229, string; 230, concatenated_string; 231, concatenated_string; 232, identifier:HALT_EXEC; 233, identifier:HALT_EXEC; 234, identifier:smr; 235, identifier:Parameters; 236, string_content:--ref; 237, identifier:refseqs_fp; 238, identifier:sortmerna_db; 239, identifier:smr; 240, identifier:Parameters; 241, string_content:--reads; 242, subscript; 243, identifier:on; 244, identifier:blast_format; 245, subscript; 246, identifier:on; 247, call; 248, subscript; 249, identifier:on; 250, identifier:smr; 251, identifier:Parameters; 252, string_content:--aligned; 253, subscript; 254, identifier:on; 255, identifier:e_value; 256, subscript; 257, identifier:on; 258, identifier:best; 259, subscript; 260, identifier:on; 261, identifier:num_alignments; 262, subscript; 263, identifier:on; 264, identifier:threads; 265, identifier:smr; 266, identifier:Parameters; 267, string_content:--fastx; 268, identifier:smr; 269, identifier:Parameters; 270, string_content:--otu_map; 271, identifier:smr; 272, identifier:Parameters; 273, string_content:--de_novo_otu; 274, identifier:smr; 275, identifier:Parameters; 276, string_content:--id; 277, identifier:smr; 278, identifier:Parameters; 279, string_content:--coverage; 280, string:"Either Blast or SAM output alignment "; 281, string:"format must be chosen."; 282, string:"Only one of --best or --num_alignments "; 283, string:"options must be chosen."; 284, attribute; 285, string; 286, attribute; 287, string; 288, attribute; 289, argument_list; 290, attribute; 291, string; 292, attribute; 293, string; 294, attribute; 295, string; 296, attribute; 297, string; 298, attribute; 299, string; 300, identifier:smr; 301, identifier:Parameters; 302, string_content:--blast; 303, identifier:smr; 304, identifier:Parameters; 305, string_content:--sam; 306, subscript; 307, identifier:on; 308, identifier:smr; 309, identifier:Parameters; 310, string_content:--print_all_reads; 311, identifier:smr; 312, identifier:Parameters; 313, string_content:-e; 314, identifier:smr; 315, identifier:Parameters; 316, string_content:--best; 317, identifier:smr; 318, identifier:Parameters; 319, string_content:--num_alignments; 320, identifier:smr; 321, identifier:Parameters; 322, string_content:-a; 323, attribute; 324, string; 325, identifier:smr; 326, identifier:Parameters; 327, string_content:--SQ
code: def sortmerna_map(seq_path,
                    output_dir,
                    refseqs_fp,
                    sortmerna_db,
                    e_value=1,
                    threads=1,
                    best=None,
                    num_alignments=None,
                    HALT_EXEC=False,
                    output_sam=False,
                    sam_SQ_tags=False,
                    blast_format=3,
                    print_all_reads=True,
                    ):
      """Launch sortmerna mapper
  
          Parameters
          ----------
          seq_path : str
              filepath to reads.
          output_dir : str
              dirpath to sortmerna output.
          refseqs_fp : str
              filepath of reference sequences.
          sortmerna_db : str
              indexed reference database.
          e_value : float, optional
              E-value threshold [default: 1].
          threads : int, optional
              number of threads to use (OpenMP) [default: 1].
          best : int, optional
              number of best alignments to output per read
              [default: None].
          num_alignments : int, optional
              number of first alignments passing E-value threshold to
              output per read [default: None].
          HALT_EXEC : bool, debugging parameter
              If passed, will exit just before the sortmerna command
              is issued and will print out the command that would
              have been called to stdout [default: False].
          output_sam : bool, optional
              flag to set SAM output format [default: False].
          sam_SQ_tags : bool, optional
              add SQ field to SAM output (if output_SAM is True)
              [default: False].
          blast_format : int, optional
              Output Blast m8 tabular + 2 extra columns for CIGAR
              string and query coverge [default: 3].
          print_all_reads : bool, optional
              output NULL alignments for non-aligned reads
              [default: True].
  
          Returns
          -------
          dict of result paths set in _get_result_paths()
      """
  
      if not (blast_format or output_sam):
          raise ValueError("Either Blast or SAM output alignment "
                           "format must be chosen.")
  
      if (best and num_alignments):
          raise ValueError("Only one of --best or --num_alignments "
                           "options must be chosen.")
  
      # Instantiate the object
      smr = Sortmerna(HALT_EXEC=HALT_EXEC)
  
      # Set the input reference sequence + indexed database path
      smr.Parameters['--ref'].on("%s,%s" % (refseqs_fp, sortmerna_db))
  
      # Set input query sequences path
      smr.Parameters['--reads'].on(seq_path)
  
      # Set Blast tabular output
      # The option --blast 3 represents an
      # m8 blast tabular output + two extra
      # columns containing the CIGAR string
      # and the query coverage
      if blast_format:
          smr.Parameters['--blast'].on(blast_format)
  
      # Output alignments in SAM format
      if output_sam:
          smr.Parameters['--sam'].on()
          if sam_SQ_tags:
              smr.Parameters['--SQ'].on()
  
      # Turn on NULL string alignment output
      if print_all_reads:
          smr.Parameters['--print_all_reads'].on()
  
      # Set output results path (for Blast alignments and log file)
      output_file = join(output_dir, "sortmerna_map")
      smr.Parameters['--aligned'].on(output_file)
  
      # Set E-value threshold
      if e_value is not None:
          smr.Parameters['-e'].on(e_value)
  
      # Set number of best alignments to output per read
      if best is not None:
          smr.Parameters['--best'].on(best)
  
      # Set number of first alignments passing E-value threshold
      # to output per read
      if num_alignments is not None:
          smr.Parameters['--num_alignments'].on(num_alignments)
  
      # Set number of threads
      if threads is not None:
          smr.Parameters['-a'].on(threads)
  
      # Turn off parameters related to OTU-picking
      smr.Parameters['--fastx'].off()
      smr.Parameters['--otu_map'].off()
      smr.Parameters['--de_novo_otu'].off()
      smr.Parameters['--id'].off()
      smr.Parameters['--coverage'].off()
  
      # Run sortmerna
      app_result = smr()
  
      return app_result