Changeset 6467


Ignore:
Timestamp:
Nov 3, 2021, 3:13:27 PM (15 months ago)
Author:
Nicklas Nordborg
Message:

References #1347: Updates to registration of specimen handled by external lab

Figure out which FASTQ is R1 and which is R2 by checking the stored annotation values instead of using the find command. The pattern used may not always match.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/grid/ImportFastqJobCreator.java

    r6421 r6467  
    187187            demuxName + " must have two values: " + rawFastqNames);
    188188      }
     189      String fastqNameR1 = null;
     190      String fastqNameR2 = null;
     191      // NOTE! Order in the list is not specified so we don't know which is R1 and R2
     192      // Search for _R1 and _R2
     193      for (String fqName : rawFastqNames)
     194      {
     195        if (fqName.contains("_R1")) fastqNameR1 = fqName;
     196        if (fqName.contains("_R2")) fastqNameR2 = fqName;
     197      }
     198      if (fastqNameR1 == null)
     199      {
     200        throw new InvalidDataException("Annotation RawFASTQ on " +
     201            demuxName + " is missing an R1 fastq file: " + rawFastqNames);
     202      }
     203      if (fastqNameR2 == null)
     204      {
     205        throw new InvalidDataException("Annotation RawFASTQ on " +
     206            demuxName + " is missing an R2 fastq file: " + rawFastqNames);
     207      }
    189208     
    190209      // Get SequencingRun so that we can get the path to the FASTQ folder.
     
    272291      // If not, we need to copy from ImportGateway
    273292      // If they don't exists at all we generate an error
    274       int fileNo = 0;
    275293      script.cmd("mkdir -p ${ImportArchive}");
    276       for (String fastqName : rawFastqNames)
    277       {
    278         fileNo++;
    279         // NOTE! Order in the list is not specified so we don't know which is R1 and R2
    280         script.cmd("FASTQ="+ScriptUtil.checkValidFilename(fastqName));
    281         script.progress(5+fileNo*5, "Copying FASTQ files: ${FASTQ}");
    282         script.cmd("if [ ! -f \"${ImportArchive}/${FASTQ}\" ]; then");
    283         script.cmd("  if [ ! -f \"${ImportGateway}/${FASTQ}\" ]; then");
    284         script.cmd("    echo \"Can't find FASTQ file ${FASTQ} in ${ImportGateway} or ${ImportArchive}\" 1>&2");
     294      script.cmd("FASTQ1="+ScriptUtil.checkValidFilename(fastqNameR1));
     295      script.cmd("FASTQ2="+ScriptUtil.checkValidFilename(fastqNameR2));
     296      for (int fileNo = 1; fileNo <= 2; fileNo++)
     297      {
     298        script.progress(5+fileNo*5, "Copying FASTQ files: ${FASTQ"+fileNo+"}");
     299        script.cmd("if [ ! -f \"${ImportArchive}/${FASTQ"+fileNo+"}\" ]; then");
     300        script.cmd("  if [ ! -f \"${ImportGateway}/${FASTQ"+fileNo+"}\" ]; then");
     301        script.cmd("    echo \"Can't find FASTQ file ${FASTQ"+fileNo+"} in ${ImportGateway} or ${ImportArchive}\" 1>&2");
    285302        script.cmd("    exit 1");
    286303        script.cmd("   fi");
    287         script.cmd("   cp \"${ImportGateway}/${FASTQ}\" \"${ImportArchive}/${FASTQ}\"");
     304        script.cmd("   cp \"${ImportGateway}/${FASTQ"+fileNo+"}\" \"${ImportArchive}/${FASTQ"+fileNo+"}\"");
    288305        if (!debug)
    289306        {
    290           script.cmd("   rm -f \"${ImportGateway}/${FASTQ}\"");
     307          script.cmd("   rm -f \"${ImportGateway}/${FASTQ"+fileNo+"}\"");
    291308        }
    292309        script.cmd("fi");
    293         script.cmd("cp \"${ImportArchive}/${FASTQ}\" fastq");
     310        script.cmd("cp \"${ImportArchive}/${FASTQ"+fileNo+"}\" fastq");
    294311        script.newLine();
    295312      }
    296      
    297       script.comment("Find FASTQ files");
    298       script.cmd("FASTQ1=`find fastq -name \"*_R1*.fastq.gz\" -print -quit 2> /dev/null`");
    299       script.cmd("FASTQ2=`find fastq -name \"*_R2*.fastq.gz\" -print -quit 2> /dev/null`");
    300       script.newLine();
    301313
    302314      script.comment("Run Bowtie2");
    303       script.progress(40, "Bowtie2: " + mergedName + " (${NumThreads} threads)");
     315      script.progress(20, "Bowtie2: " + mergedName + " (${NumThreads} threads)");
    304316      String alignCmd = "./stdwrap.sh " + bowtie_path;
    305317      alignCmd += " -p ${NumThreads}";
     
    307319      alignCmd += " --un-conc fastq.aligned/R%.fastq";
    308320      alignCmd += " -x ${Gidx}";
    309       alignCmd += " -1 ${FASTQ1}";
    310       alignCmd += " -2 ${FASTQ2}";
     321      alignCmd += " -1 fastq/${FASTQ1}";
     322      alignCmd += " -2 fastq/${FASTQ2}";
    311323      alignCmd += " -S fastq.aligned/aligned.sam";
    312324      alignCmd += " > fastq.aligned/aligned.out";
     
    319331      String trimCmd1 = "./stdwrap.sh ./trimmomatic PE";
    320332      trimCmd1 += " -threads ${NumThreads}";
    321       trimCmd1 += " ${FASTQ1}";
    322       trimCmd1 += " ${FASTQ2}";
     333      trimCmd1 += " fastq/${FASTQ1}";
     334      trimCmd1 += " fastq/${FASTQ2}";
    323335      trimCmd1 += " fastq.trimmomatic.1/"+R1_name;
    324336      trimCmd1 += " fastq.trimmomatic.1/un_"+R1_name;
Note: See TracChangeset for help on using the changeset viewer.