diff --git a/mapping/src/main/java/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala b/mapping/src/main/java/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala
index bbb5e66d35c687584d35683a1d997cf29ad23d4a..0d9497c39ce9c0667b8d7e5d3c2b68dd49e8f856 100644
--- a/mapping/src/main/java/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala
+++ b/mapping/src/main/java/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala
@@ -88,11 +88,23 @@ class Mapping(private var globalConfig: Config) extends QScript with BiopetQScri
       add(bwaCommand)
       bamFile = addSortSam(List(bwaCommand.output), swapExt(outputDir,bwaCommand.output,".sam",".bam"), outputDir)
     } else if (aligner == "star") {
-      val starCommand = new Star(config) { R1 = fastq_R1; if (paired) R2 = fastq_R2; this.outputDir = qscript.outputDir + "star/" ;
-                                          outputSam = new File(this.outputDir + "/Aligned.out.sam") }
+      val starCommand = new Star(config) { R1 = fastq_R1; if (paired) R2 = fastq_R2; this.outputDir = qscript.outputDir + "star/"; init}
       add(starCommand)
       bamFile = addAddOrReplaceReadGroups(List(starCommand.outputSam), swapExt(outputDir,starCommand.outputSam,".sam",".bam"), outputDir)
-    }
+    } else if (aligner == "star-2pass") {
+      val starCommand_pass1 = new Star(config) { R1 = fastq_R1; if (paired) R2 = fastq_R2;
+            this.outputDir = qscript.outputDir + "star-2pass/aln-pass1/"; init}
+      add(starCommand_pass1)
+      
+      val starCommand_reindex = new Star(config) { this.sjdbFileChrStartEnd = starCommand_pass1.outputTab;
+            this.outputDir = qscript.outputDir + "star-2pass/re-index/" ; this.runmode = "genomeGenerate"; this.sjdbOverhang = 75; init}
+      add(starCommand_reindex)
+      
+      val starCommand_pass2 = new Star(config) { R1 = fastq_R1; if (paired) R2 = fastq_R2; this.deps ++= starCommand_reindex.outputs;
+            this.outputDir = qscript.outputDir + "star-2pass/aln-pass2/"; this.genomeDir = starCommand_reindex.outputDir; init}
+      add(starCommand_pass2)
+      bamFile = addAddOrReplaceReadGroups(List(starCommand_pass2.outputSam), swapExt(outputDir,starCommand_pass2.outputSam,".sam",".bam"), outputDir)
+    } else throw new IllegalStateException("Option Alginer: '" + aligner + "' is not valid")
     
     if (!skipMarkduplicates) bamFile = addMarkDuplicates(List(bamFile), swapExt(outputDir,bamFile,".bam",".dedup.bam"), outputDir)
     outputFiles += ("finalBamFile" -> bamFile)
@@ -164,6 +176,9 @@ class Mapping(private var globalConfig: Config) extends QScript with BiopetQScri
   }
   
   def loadRunConfig(runConfig:Config, sampleConfig:Config, runDir: String) {
+    config = Config.mergeConfigs(globalConfig.getAsConfig("mapping"), globalConfig)
+    val inputType = runConfig.getAsString("inputtype", config.getAsString("inputtype", "dna"))
+    if (inputType == "rna") aligner = config.getAsString("rna_aligner", "star-2pass")
     input_R1 = runConfig.getAsString("R1", null)
     input_R2 = runConfig.getAsString("R2", null)
     paired = (input_R2 != null)
diff --git a/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Star.scala b/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Star.scala
index 663344054257024f8ed3ec2018770a5efb881a0d..06f4d4371fd0c7e7df4443b0433f33ee4cf08732 100644
--- a/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Star.scala
+++ b/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Star.scala
@@ -12,38 +12,53 @@ class Star(val globalConfig: Config) extends CommandLineFunction {
   val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
   
-  @Argument(doc="STAR executeble", shortName="star_exe", required=false)
-  var star_exe: String = config.getAsString("exe", "/usr/local/bin/STAR")
-  @Input(doc="The reference file for the bam files.", shortName="R") var referenceFile: File = new File(config.getAsString("referenceFile"))
-  @Input(doc="Fastq file R1", shortName="R1") var R1: File = _
-  @Input(doc="Fastq file R2", shortName="R2", required=false) var R2: File = _
-  @Argument(doc="Output Directory", shortName="outputDir") var outputDir: String = _
-  @Argument(doc="GenomeDir", required=false) var genomeDir: String = config.getAsString("genomeDir", referenceFile.getParent + "/star")
+  @Argument(doc="STAR executeble", required=false) var star_exe: String = config.getAsString("exe", "/usr/local/bin/STAR")
+  @Input(doc="The reference file for the bam files.", required=false) var referenceFile: File = new File(config.getAsString("referenceFile"))
+  @Input(doc="Fastq file R1", required=false) var R1: File = _
+  @Input(doc="Fastq file R2", required=false) var R2: File = _
+  @Argument(doc="Output Directory") var outputDir: String = _
+  @Argument(doc="GenomeDir", required=false) var genomeDir: String = config.getAsString("genomeDir", referenceFile.getParent + "/star/")
   @Argument(doc="STAR runmode", shortName="runmode", required=false) var runmode: String = _
-  @Output var outputSam: File = new File(outputDir + "/Aligned.out.sam")
+  @Output(doc="Output SAM file", required=false) var outputSam: File = _
+  @Output(doc="Output tab file", required=false) var outputTab: File = _
+  @Input(doc="sjdbFileChrStartEnd file", required=false) var sjdbFileChrStartEnd: File = _
+  @Argument(doc="sjdbOverhang", required=false) var sjdbOverhang: Int = _
+  @Input(doc="deps", required=false) var deps: List[File] = Nil
+  
+  @Output(doc="Output genome file", required=false) var outputGenome: File = _
+  @Output(doc="Output SA file", required=false) var outputSA: File = _
+  @Output(doc="Output SAindex file", required=false) var outputSAindex: File = _
   
   jobResourceRequests :+= "h_vmem=" + config.getAsString("vmem", "6G")
-  var threads: Int = config.getAsInt("threads", 8)
-  var maxThreads: Int = config.getAsInt("maxthreads", 24)
-  if (threads > maxThreads) threads = maxThreads
-  nCoresRequest = Option(threads)
+  nCoresRequest = Option(config.getThreads(8))
   
   def init() {
     this.addJobReportBinding("version", "NA")
+    if (runmode == null) {
+      outputSam = new File(outputDir + "/Aligned.out.sam")
+      outputTab = new File(outputDir + "/SJ.out.tab")
+    } else if (runmode == "genomeGenerate") {
+      genomeDir = outputDir
+      outputGenome = new File(genomeDir + "/Genome")
+      outputSA = new File(genomeDir + "/SA")
+      outputSAindex = new File(genomeDir + "/SAindex")
+    }
   }
   
   def commandLine : String= {
     init()
     var cmd: String = required("cd",outputDir) + "&&" + required(star_exe)
     if (runmode != null && runmode == "genomeGenerate") { // Create index
-      cmd += required("--runmode", runmode) +
-        required("--genomeDir", genomeDir) +
+      cmd += required("--runMode", runmode) +
+        //required("--genomeDir", genomeDir) +
         required("--genomeFastaFiles", referenceFile)
     } else { // Aligner
-      cmd += required("--genomeDir", genomeDir) +
-        required("--readFilesIn", R1) + optional(R2)
+      cmd += required("--readFilesIn", R1) + optional(R2)
     }
-    cmd += optional("--runThreadN", nCoresRequest)
+    cmd += required("--genomeDir", genomeDir) +
+      optional("--sjdbFileChrStartEnd", sjdbFileChrStartEnd) +
+      optional("--runThreadN", nCoresRequest)
+    if (sjdbOverhang > 0) cmd += optional("--sjdbOverhang", sjdbOverhang)
     
     return cmd
   }