nodes: 0, module; 1, function_definition; 2, function_name:run_star; 3, parameters; 4, block; 5, identifier:job; 6, identifier:fastqs; 7, identifier:univ_options; 8, identifier:star_options; 9, expression_statement; 10, assert_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, if_statement; 17, expression_statement; 18, for_statement; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, expression_statement; 24, return_statement; 25, comment:"""
      This module uses STAR to align the RNA fastqs to the reference
  
      ARGUMENTS
      1. fastqs: REFER RETURN VALUE of run_cutadapt()
      2. univ_options: Dict of universal arguments used by almost all tools
           univ_options
                +- 'dockerhub': <dockerhub to use>
      3. star_options: Dict of parameters specific to STAR
           star_options
               |- 'index_tar': <JSid for the STAR index tarball>
               +- 'n': <number of threads to allocate>
      RETURN VALUES
      1. output_files: Dict of aligned bams
           output_files
               |- 'rnaAligned.toTranscriptome.out.bam': <JSid>
               +- 'rnaAligned.sortedByCoord.out.bam': Dict of genome bam + bai
                                  |- 'rna_fix_pg_sorted.bam': <JSid>
                                  +- 'rna_fix_pg_sorted.bam.bai': <JSid>
  
      This module corresponds to node 9 on the tree
      """; 26, comparison_operator:star_options['type'] in ('star', 'starlong'); 27, call; 28, assignment; 29, assignment; 30, assignment; 31, assignment; 32, comparison_operator:star_options['type'] == 'star'; 33, block; 34, else_clause; 35, assignment; 36, identifier:bam_file; 37, list; 38, block; 39, call; 40, call; 41, assignment; 42, call; 43, assignment; 44, identifier:output_files; 45, subscript; 46, tuple; 47, attribute; 48, argument_list; 49, identifier:work_dir; 50, call; 51, identifier:input_files; 52, dictionary; 53, identifier:input_files; 54, call; 55, identifier:parameters; 56, list; 57, subscript; 58, string; 59, expression_statement; 60, block; 61, identifier:output_files; 62, call; 63, string; 64, string; 65, expression_statement; 66, attribute; 67, argument_list; 68, attribute; 69, argument_list; 70, identifier:index_star; 71, call; 72, attribute; 73, argument_list; 74, subscript; 75, call; 76, identifier:star_options; 77, string; 78, string; 79, string; 80, attribute; 81, identifier:logToMaster; 82, binary_operator:'Running STAR on %s' %univ_options['patient']; 83, attribute; 84, argument_list; 85, pair; 86, pair; 87, pair; 88, identifier:get_files_from_filestore; 89, argument_list; 90, string; 91, call; 92, string; 93, subscript; 94, string; 95, string; 96, string; 97, subscript; 98, subscript; 99, string; 100, string; 101, string; 102, string; 103, string; 104, string; 105, string; 106, string; 107, string; 108, string; 109, string; 110, string; 111, string; 112, identifier:star_options; 113, string; 114, string_content:star; 115, call; 116, expression_statement; 117, identifier:defaultdict; 118, argument_list; 119, string_content:rnaAligned.toTranscriptome.out.bam; 120, string_content:rnaAligned.sortedByCoord.out.bam; 121, assignment; 122, attribute; 123, identifier:deleteGlobalFile; 124, subscript; 125, attribute; 126, identifier:deleteGlobalFile; 127, subscript; 128, attribute; 129, argument_list; 130, identifier:job; 131, identifier:addChild; 132, identifier:index_star; 133, identifier:output_files; 134, string; 135, attribute; 136, argument_list; 137, string_content:type; 138, string_content:star; 139, string_content:starlong; 140, identifier:job; 141, identifier:fileStore; 142, string; 143, subscript; 144, attribute; 145, identifier:getLocalTempDir; 146, string; 147, subscript; 148, string; 149, subscript; 150, string; 151, subscript; 152, identifier:job; 153, identifier:input_files; 154, identifier:work_dir; 155, keyword_argument; 156, string_content:--runThreadN; 157, identifier:str; 158, argument_list; 159, string_content:--genomeDir; 160, identifier:input_files; 161, string; 162, string_content:--outFileNamePrefix; 163, string_content:rna; 164, string_content:--readFilesIn; 165, identifier:input_files; 166, string; 167, identifier:input_files; 168, string; 169, string_content:--outSAMattributes; 170, string_content:NH; 171, string_content:HI; 172, string_content:AS; 173, string_content:NM; 174, string_content:MD; 175, string_content:--outSAMtype; 176, string_content:BAM; 177, string_content:SortedByCoordinate; 178, string_content:--quantMode; 179, string_content:TranscriptomeSAM; 180, string_content:--outSAMunmapped; 181, string_content:Within; 182, string_content:type; 183, identifier:docker_call; 184, argument_list; 185, call; 186, subscript; 187, call; 188, identifier:job; 189, identifier:fileStore; 190, identifier:fastqs; 191, string; 192, identifier:job; 193, identifier:fileStore; 194, identifier:fastqs; 195, string; 196, identifier:job; 197, identifier:wrapJobFn; 198, identifier:index_bamfile; 199, subscript; 200, string; 201, identifier:univ_options; 202, keyword_argument; 203, string_content:rnaAligned.sortedByCoord.out.bam; 204, identifier:index_star; 205, identifier:rv; 206, string_content:Running STAR on %s; 207, identifier:univ_options; 208, string; 209, identifier:job; 210, identifier:fileStore; 211, string_content:rna_cutadapt_1.fastq; 212, identifier:fastqs; 213, string; 214, string_content:rna_cutadapt_2.fastq; 215, identifier:fastqs; 216, string; 217, string_content:star_index.tar.gz; 218, identifier:star_options; 219, string; 220, identifier:docker; 221, True; 222, subscript; 223, string_content:star_index; 224, string_content:rna_cutadapt_1.fastq; 225, string_content:rna_cutadapt_2.fastq; 226, keyword_argument; 227, keyword_argument; 228, keyword_argument; 229, keyword_argument; 230, identifier:docker_call; 231, argument_list; 232, identifier:output_files; 233, identifier:bam_file; 234, attribute; 235, argument_list; 236, string_content:rna_cutadapt_1.fastq; 237, string_content:rna_cutadapt_2.fastq; 238, identifier:output_files; 239, string; 240, string_content:rna; 241, identifier:disk; 242, string; 243, string_content:patient; 244, string_content:rna_cutadapt_1.fastq; 245, string_content:rna_cutadapt_2.fastq; 246, string_content:index_tar; 247, identifier:star_options; 248, string; 249, identifier:tool; 250, string; 251, identifier:tool_parameters; 252, identifier:parameters; 253, identifier:work_dir; 254, identifier:work_dir; 255, identifier:dockerhub; 256, subscript; 257, keyword_argument; 258, keyword_argument; 259, keyword_argument; 260, keyword_argument; 261, attribute; 262, identifier:writeGlobalFile; 263, call; 264, string_content:rnaAligned.sortedByCoord.out.bam; 265, string_content:120G; 266, string_content:n; 267, string_content:star; 268, identifier:univ_options; 269, string; 270, identifier:tool; 271, string; 272, identifier:tool_parameters; 273, identifier:parameters; 274, identifier:work_dir; 275, identifier:work_dir; 276, identifier:dockerhub; 277, subscript; 278, identifier:job; 279, identifier:fileStore; 280, attribute; 281, argument_list; 282, string_content:dockerhub; 283, string_content:starlong; 284, identifier:univ_options; 285, string; 286, string; 287, identifier:join; 288, list; 289, string_content:dockerhub; 290, string_content:/; 291, identifier:work_dir; 292, identifier:bam_file
code: def run_star(job, fastqs, univ_options, star_options):
      """
      This module uses STAR to align the RNA fastqs to the reference
  
      ARGUMENTS
      1. fastqs: REFER RETURN VALUE of run_cutadapt()
      2. univ_options: Dict of universal arguments used by almost all tools
           univ_options
                +- 'dockerhub': <dockerhub to use>
      3. star_options: Dict of parameters specific to STAR
           star_options
               |- 'index_tar': <JSid for the STAR index tarball>
               +- 'n': <number of threads to allocate>
      RETURN VALUES
      1. output_files: Dict of aligned bams
           output_files
               |- 'rnaAligned.toTranscriptome.out.bam': <JSid>
               +- 'rnaAligned.sortedByCoord.out.bam': Dict of genome bam + bai
                                  |- 'rna_fix_pg_sorted.bam': <JSid>
                                  +- 'rna_fix_pg_sorted.bam.bai': <JSid>
  
      This module corresponds to node 9 on the tree
      """
      assert star_options['type'] in ('star', 'starlong')
      job.fileStore.logToMaster('Running STAR on %s' %univ_options['patient'])
      work_dir = job.fileStore.getLocalTempDir()
      input_files = {
          'rna_cutadapt_1.fastq': fastqs['rna_cutadapt_1.fastq'],
          'rna_cutadapt_2.fastq': fastqs['rna_cutadapt_2.fastq'],
          'star_index.tar.gz': star_options['index_tar']}
      input_files = get_files_from_filestore(job, input_files, work_dir,
                                             docker=True)
      parameters = ['--runThreadN', str(star_options['n']),
                    '--genomeDir', input_files['star_index'],
                    '--outFileNamePrefix', 'rna',
                    '--readFilesIn',
                    input_files['rna_cutadapt_1.fastq'],
                    input_files['rna_cutadapt_2.fastq'],
                    '--outSAMattributes', 'NH', 'HI', 'AS', 'NM', 'MD',
                    '--outSAMtype', 'BAM', 'SortedByCoordinate',
                    '--quantMode', 'TranscriptomeSAM',
                    '--outSAMunmapped', 'Within']
      if star_options['type'] == 'star':
          docker_call(tool='star', tool_parameters=parameters, work_dir=work_dir,
                      dockerhub=univ_options['dockerhub'])
      else:
          docker_call(tool='starlong', tool_parameters=parameters, work_dir=work_dir,
                      dockerhub=univ_options['dockerhub'])
      output_files = defaultdict()
      for bam_file in ['rnaAligned.toTranscriptome.out.bam',
                       'rnaAligned.sortedByCoord.out.bam']:
          output_files[bam_file] = job.fileStore.writeGlobalFile('/'.join([
              work_dir, bam_file]))
      job.fileStore.deleteGlobalFile(fastqs['rna_cutadapt_1.fastq'])
      job.fileStore.deleteGlobalFile(fastqs['rna_cutadapt_2.fastq'])
      index_star = job.wrapJobFn(index_bamfile,
                                 output_files['rnaAligned.sortedByCoord.out.bam'],
                                 'rna', univ_options, disk='120G')
      job.addChild(index_star)
      output_files['rnaAligned.sortedByCoord.out.bam'] = index_star.rv()
      return output_files