Skip to content

Commit

Permalink
#410 added locking to setupreference step
Browse files Browse the repository at this point in the history
switched to always creating {REFERENCE}.dict during sequence dictionary check
  • Loading branch information
Daniel Cameron committed Oct 20, 2020
1 parent fb99b7c commit fae0fb5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
39 changes: 30 additions & 9 deletions scripts/gridss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -518,23 +518,44 @@ if [[ "$useproperpair" == "true" ]] ; then
fi

if [[ $do_setupreference == true ]] ; then
lock_file=$reference.tmp.gridsslock
if [[ ! -f ${reference}.fai ]] && [[ ! -f $(basename $reference .fa).fai ]] && [[ ! -f $(basename $reference .fasta).fai ]] ; then
write_status "Running samtools faidx (once-off setup for reference genome)"
$timecmd samtools faidx $reference 1>&2 2>> $logfile
if mkdir $lock_file ; then
write_status "Running samtools faidx (once-off setup for reference genome)"
$timecmd samtools faidx $reference 1>&2 2>> $logfile
rmdir $lock_file
else
write_status "Multiple instances of setupreference cannot be run concurrently. Aborting due to existence of $lock_file"
exit $EX_CANTCREAT
fi
fi
if [[ ! -f ${reference}.bwt ]] ; then
write_status "Running bwa index (once-off setup for reference genome)"
$timecmd bwa index $reference 1>&2 2>> $logfile
if mkdir $lock_file ; then
write_status "Running bwa index (once-off setup for reference genome)"
$timecmd bwa index $reference 1>&2 2>> $logfile
rmdir $lock_file
else
write_status "Multiple instances of setupreference cannot be run concurrently. Aborting due to existence of $lock_file"
exit $EX_CANTCREAT
fi
fi
#if [[ ! -f ${reference}.idx ]] ; then
# write_status "Running minimap2 index (once-off setup for reference genome)"
# $timecmd minimap2 -d ${reference}.idx ${reference} 1>&2 2>> $logfile
#fi
write_status "Running PrepareReference (once-off setup for reference genome)"
$timecmd java -Xmx4g $jvm_args \
-cp $gridss_jar gridss.PrepareReference \
REFERENCE_SEQUENCE=$reference \
1>&2 2>> $logfile
if [[ ! -f ${reference}.gridsscache ]] || [[ ! -f ${reference}.img ]] || [[ ! -f ${reference}.dict ]] ; then
if mkdir $lock_file ; then
write_status "Running PrepareReference (once-off setup for reference genome)"
$timecmd java -Xmx4g $jvm_args \
-cp $gridss_jar gridss.PrepareReference \
REFERENCE_SEQUENCE=$reference \
1>&2 2>> $logfile
rmdir $lock_file
else
write_status "Multiple instances of setupreference cannot be run concurrently. Aborting due to existence of $lock_file"
exit $EX_CANTCREAT
fi
fi
fi

if [[ $do_preprocess == true ]] ; then
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gridss/cmdline/ReferenceCommandLineProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public ReferenceLookup getReference() {
public static boolean ensureSequenceDictionary(File referenceFile) {
try (ReferenceSequenceFile rsf = new FastaSequenceFile(referenceFile, false)) {
Path path = referenceFile.toPath().toAbsolutePath();
if (rsf.getSequenceDictionary() == null) {
Path dictPath = path.resolveSibling(path.getFileName().toString() + FileExtensions.DICT);
if (!dictPath.toFile().exists()) {
log.info("Attempting to create sequence dictionary for " + referenceFile);
Path dictPath = path.resolveSibling(path.getFileName().toString() + FileExtensions.DICT);
CommandLineProgramHelper cmd = new CommandLineProgramHelper(new picard.sam.CreateSequenceDictionary());
cmd.addArg("OUTPUT", dictPath.toFile());
cmd.addArg("R", referenceFile.getPath());
Expand Down

0 comments on commit fae0fb5

Please sign in to comment.