nodes: 0, module; 1, function_definition; 2, function_name:sam_conversions; 3, parameters; 4, block; 5, identifier:self; 6, identifier:sam_file; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, return_statement; 14, identifier:depth; 15, True; 16, comment:"""
          Convert sam files to bam files, then sort and index them for later use.
  
          :param bool depth: also calculate coverage over each position
          """; 17, assignment; 18, augmented_assignment; 19, augmented_assignment; 20, identifier:depth; 21, block; 22, identifier:cmd; 23, identifier:cmd; 24, binary_operator:self.tools.samtools + " view -bS " + sam_file + " > " + sam_file.replace(".sam", ".bam") + "\n"; 25, identifier:cmd; 26, binary_operator:self.tools.samtools + " sort " + sam_file.replace(".sam", ".bam") + " -o " + sam_file.replace(".sam", "_sorted.bam") + "\n"; 27, identifier:cmd; 28, binary_operator:self.tools.samtools + " index " + sam_file.replace(".sam", "_sorted.bam") + "\n"; 29, expression_statement; 30, binary_operator:self.tools.samtools + " view -bS " + sam_file + " > " + sam_file.replace(".sam", ".bam"); 31, string:"\n"; 32, binary_operator:self.tools.samtools + " sort " + sam_file.replace(".sam", ".bam") + " -o " + sam_file.replace(".sam", "_sorted.bam"); 33, string:"\n"; 34, binary_operator:self.tools.samtools + " index " + sam_file.replace(".sam", "_sorted.bam"); 35, string:"\n"; 36, augmented_assignment; 37, binary_operator:self.tools.samtools + " view -bS " + sam_file + " > "; 38, call; 39, binary_operator:self.tools.samtools + " sort " + sam_file.replace(".sam", ".bam") + " -o "; 40, call; 41, binary_operator:self.tools.samtools + " index "; 42, call; 43, identifier:cmd; 44, binary_operator:self.tools.samtools + " depth " + sam_file.replace(".sam", "_sorted.bam") + " > " + sam_file.replace(".sam", "_sorted.depth") + "\n"; 45, binary_operator:self.tools.samtools + " view -bS " + sam_file; 46, string:" > "; 47, attribute; 48, argument_list; 49, binary_operator:self.tools.samtools + " sort " + sam_file.replace(".sam", ".bam"); 50, string:" -o "; 51, attribute; 52, argument_list; 53, attribute; 54, string:" index "; 55, attribute; 56, argument_list; 57, binary_operator:self.tools.samtools + " depth " + sam_file.replace(".sam", "_sorted.bam") + " > " + sam_file.replace(".sam", "_sorted.depth"); 58, string:"\n"; 59, binary_operator:self.tools.samtools + " view -bS "; 60, identifier:sam_file; 61, identifier:sam_file; 62, identifier:replace; 63, string:".sam"; 64, string:".bam"; 65, binary_operator:self.tools.samtools + " sort "; 66, call; 67, identifier:sam_file; 68, identifier:replace; 69, string:".sam"; 70, string:"_sorted.bam"; 71, attribute; 72, identifier:samtools; 73, identifier:sam_file; 74, identifier:replace; 75, string:".sam"; 76, string:"_sorted.bam"; 77, binary_operator:self.tools.samtools + " depth " + sam_file.replace(".sam", "_sorted.bam") + " > "; 78, call; 79, attribute; 80, string:" view -bS "; 81, attribute; 82, string:" sort "; 83, attribute; 84, argument_list; 85, identifier:self; 86, identifier:tools; 87, binary_operator:self.tools.samtools + " depth " + sam_file.replace(".sam", "_sorted.bam"); 88, string:" > "; 89, attribute; 90, argument_list; 91, attribute; 92, identifier:samtools; 93, attribute; 94, identifier:samtools; 95, identifier:sam_file; 96, identifier:replace; 97, string:".sam"; 98, string:".bam"; 99, binary_operator:self.tools.samtools + " depth "; 100, call; 101, identifier:sam_file; 102, identifier:replace; 103, string:".sam"; 104, string:"_sorted.depth"; 105, identifier:self; 106, identifier:tools; 107, identifier:self; 108, identifier:tools; 109, attribute; 110, string:" depth "; 111, attribute; 112, argument_list; 113, attribute; 114, identifier:samtools; 115, identifier:sam_file; 116, identifier:replace; 117, string:".sam"; 118, string:"_sorted.bam"; 119, identifier:self; 120, identifier:tools
code: def sam_conversions(self, sam_file, depth=True):
          """
          Convert sam files to bam files, then sort and index them for later use.
  
          :param bool depth: also calculate coverage over each position
          """
          cmd = self.tools.samtools + " view -bS " + sam_file + " > " + sam_file.replace(".sam", ".bam") + "\n"
          cmd += self.tools.samtools + " sort " + sam_file.replace(".sam", ".bam") + " -o " + sam_file.replace(".sam", "_sorted.bam") + "\n"
          cmd += self.tools.samtools + " index " + sam_file.replace(".sam", "_sorted.bam") + "\n"
          if depth:
              cmd += self.tools.samtools + " depth " + sam_file.replace(".sam", "_sorted.bam") + " > " + sam_file.replace(".sam", "_sorted.depth") + "\n"
          return cmd