Skip to content

Commit

Permalink
STREL-976 Preserve softlinks in input ref paths
Browse files Browse the repository at this point in the history
This change makes reference fasta file path cleaning consistent across all
applications and between reference and alignment files. In all cases, it
makes the lookup of samtools sidecar-style index files more reliable.
  • Loading branch information
ctsa committed Aug 14, 2018
1 parent bb85e33 commit d18ddf3
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#
# Using sudo-false/container-based tests for greater (linux) test responsiveness. This doesn't seem
# to effect the queing time for OSX tests.
# to effect the queueing time for OSX tests.
#

dist: trusty
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v2.9.7 - 2018-08-14

This is a minor bugfix update from v2.9.6.

### Fixed
- Preserve softlinks in input reference fasta file paths (STREL-976)

## v2.9.6 - 2018-07-17

This is a minor bugfix update from v2.9.5.
Expand Down
4 changes: 2 additions & 2 deletions src/c++/lib/applications/GetChromDepth/ChromDepthOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ parseOptions(
ChromDepthOptions& opt,
std::string& errorMsg)
{
if (checkStandardizeInputFile(opt.alignmentFilename, "alignment", errorMsg)) return true;
if (checkStandardizeInputFile(opt.referenceFilename, "reference fasta", errorMsg)) return true;
if (checkAndStandardizeRequiredInputFilePath(opt.alignmentFilename, "alignment", errorMsg)) return true;
if (checkAndStandardizeRequiredInputFilePath(opt.referenceFilename, "reference fasta", errorMsg)) return true;

if (vm.count("chrom"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ parseOptions(
RegionDepthOptions& opt,
std::string& errorMsg)
{
if (checkStandardizeInputFile(opt.alignmentFilename, "alignment", errorMsg)) return true;
if (checkStandardizeInputFile(opt.referenceFilename, "reference fasta", errorMsg)) return true;
if (checkAndStandardizeRequiredInputFilePath(opt.alignmentFilename, "alignment", errorMsg)) return true;
if (checkAndStandardizeRequiredInputFilePath(opt.referenceFilename, "reference fasta", errorMsg)) return true;

if (vm.count("region"))
{
Expand Down
22 changes: 0 additions & 22 deletions src/c++/lib/blt_util/compat_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,6 @@
#include <iostream>


#ifdef _MSC_VER
#include "compat_util_win32_realpath.c"
#endif



bool
compat_realpath(std::string& path)
{
errno=0;
const char* newpath(realpath(path.c_str(),nullptr));
if ((nullptr==newpath) || (errno!=0))
{
if (nullptr!=newpath) free((void*)newpath);
return false;
}
path = newpath;
free((void*)newpath);
return true;
}



double
compat_round(const double x)
Expand Down
6 changes: 0 additions & 6 deletions src/c++/lib/blt_util/compat_util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,3 @@ compat_round(const double x);

const char*
compat_basename(const char* s);


// gets canonical name of paths, but only when these refer to existing items
// returns false on error.
bool
compat_realpath(std::string& path);
95 changes: 0 additions & 95 deletions src/c++/lib/blt_util/compat_util_win32_realpath.c

This file was deleted.

2 changes: 1 addition & 1 deletion src/c++/lib/options/AlignmentFileOptionsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ checkOptions(
std::set<std::string> nameCheck;
for (std::string& afile : opt.alignmentFilenames)
{
if (checkStandardizeInputFile(afile,"alignment file",errorMsg)) break;
if (checkAndStandardizeRequiredInputFilePath(afile, "alignment file", errorMsg)) break;
if (nameCheck.count(afile))
{
std::ostringstream oss;
Expand Down
2 changes: 1 addition & 1 deletion src/c++/lib/options/optionsUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


bool
checkStandardizeInputFile(
checkAndStandardizeRequiredInputFilePath(
std::string& filename,
const char* fileLabel,
std::string& errorMsg)
Expand Down
8 changes: 3 additions & 5 deletions src/c++/lib/options/optionsUtil.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
#include <string>


/// check if input file exists and is usable as
/// input, if so canonicalize the name
/// Check if input path exists and is usable as input, if so, convert the input filename to an absolute path.
///
/// In case of error return true and provide error
/// message
/// In case of error return true and provide error message
bool
checkStandardizeInputFile(
checkAndStandardizeRequiredInputFilePath(
std::string& filename,
const char* fileLabel,
std::string& errorMsg);
28 changes: 17 additions & 11 deletions src/c++/lib/starling_common/starling_base_option_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "blt_common/blt_arg_validate.hh"
#include "blt_util/compat_util.hh"
#include "options/optionsUtil.hh"
#include "starling_common/Tier2OptionsParser.hh"

#include "boost/filesystem.hpp"
Expand Down Expand Up @@ -169,13 +170,15 @@ finalize_starling_base_options(
pinfo.usage("Must specify a fasta reference file");
}

// canonicalize the reference sequence path:
/// TODO: replace this with the same thing from boost?
if (! compat_realpath(opt.referenceFilename))
// Convert reference sequence path to an absolute path. Just like for BAM/CRAM files, we want absolute but not
// canonical path in this case, because following softlinks to the canonical path will often cause us to miss the
// sidecar index file.
{
std::ostringstream oss;
oss << "can't resolve reference path: " << opt.referenceFilename << "\n";
pinfo.usage(oss.str().c_str());
std::string errorMsg;
if (checkAndStandardizeRequiredInputFilePath(opt.referenceFilename, "reference fasta", errorMsg))
{
pinfo.usage(errorMsg.c_str());
}
}

// set analysis regions:
Expand Down Expand Up @@ -226,12 +229,15 @@ finalize_starling_base_options(
{
checkOptionalInputFile(pinfo, indelErrorModelFilename, "indel error models");
}
/// tier2 options are not parsed by starling_base, but need to live up here for now,
/// so validate them together with the rest of starling_base
std::string errorMsg;
if (parseTier2Options(vm,opt.tier2,errorMsg))

// tier2 options are not parsed by starling_base, but need to live up here for now,
// so validate them together with the rest of starling_base
{
pinfo.usage(errorMsg.c_str());
std::string errorMsg;
if (parseTier2Options(vm, opt.tier2, errorMsg))
{
pinfo.usage(errorMsg.c_str());
}
}

if (opt.useTier2Evidence)
Expand Down

0 comments on commit d18ddf3

Please sign in to comment.