Commit 56c64385 authored by Neil Kindlon's avatar Neil Kindlon
Browse files

Changed -nonamecheck to warning only, added to help for map, closest, jaccard

parent 488b0593
......@@ -114,6 +114,11 @@ void closest_help(void) {
cerr << "\t-header\t" << "Print the header from the A file prior to results." << endl << endl;
cerr << "\t-nonamecheck\t" << "For sorted data, don't throw an error if the file has different naming conventions" << endl;
cerr << "\t\t\tfor the same chromosome. ex. \"chr1\" vs \"chr01\"." << endl << endl;
cerr << "Notes: " << endl;
cerr << "\tReports \"none\" for chrom and \"-1\" for all other fields when a feature" << endl;
cerr << "\tis not found in B on the same chromosome as the feature in A." << endl;
......
......@@ -73,6 +73,11 @@ void jaccard_help(void) {
cerr << "\t\t" << "the forward or reverse strand, respectively." << endl;
cerr << "\t\t" << "- By default, merging is done without respect to strand." << endl << endl;
cerr << "\t-nonamecheck\t" << "For sorted data, don't throw an error if the file has different naming conventions" << endl;
cerr << "\t\t\tfor the same chromosome. ex. \"chr1\" vs \"chr01\"." << endl << endl;
cerr << "Notes: " << endl;
cerr << "\t(1) Input files must be sorted by chrom, then start position."
<< endl << endl;
......
......@@ -84,6 +84,10 @@ void map_help(void) {
cerr << "\t-prec\t" << "Sets the decimal precision for output (Default: 5)" << endl << endl;
cerr << "\t-nonamecheck\t" << "For sorted data, don't throw an error if the file has different naming conventions" << endl;
cerr << "\t\t\tfor the same chromosome. ex. \"chr1\" vs \"chr01\"." << endl << endl;
cerr << "Notes: " << endl;
cerr << "\t(1) Both input files must be sorted by chrom, then start." << endl << endl;
......
......@@ -60,7 +60,8 @@ ContextBase::ContextBase()
_useMergedIntervals(false),
_reportPrecision(-1),
_allFilesHaveChrInChromNames(UNTESTED),
_allFileHaveLeadingZeroInChromNames(UNTESTED)
_allFileHaveLeadingZeroInChromNames(UNTESTED),
_nameConventionWarningTripped(false)
{
_programNames["intersect"] = INTERSECT;
......@@ -92,6 +93,12 @@ ContextBase::~ContextBase()
_keyListOps = NULL;
}
// if there was a warning about file name conventions,
// print it again so it's not lost amid large output.
if (_nameConventionWarningTripped) {
cerr << _nameConventionWarningMsg << endl;
}
}
bool ContextBase::determineOutputType() {
......@@ -626,7 +633,7 @@ bool ContextBase::parseIoBufSize(QuickString bufStr)
}
void ContextBase::testNameConventions(const Record *record) {
if (getNameCheckDisabled()) return;
if (getNameCheckDisabled() || _nameConventionWarningTripped) return;
int fileIdx = record->getFileIdx();
......@@ -640,14 +647,10 @@ void ContextBase::testNameConventions(const Record *record) {
if (testChrVal == UNTESTED) {
_fileHasChrInChromNames[fileIdx] = hasChr ? YES : NO;
} else if ((testChrVal == YES && !hasChr) || (testChrVal == NO && hasChr)) {
fprintf(stderr, "ERROR: File %s has inconsistent naming convention for record:\n", _fileNames[fileIdx].c_str());
record->print(stderr, true);
exit(1);
nameConventionWarning(record, _fileNames[fileIdx], " has inconsistent naming convention for record:\n");
}
if ((_allFilesHaveChrInChromNames == YES && !hasChr) || (_allFilesHaveChrInChromNames == NO && hasChr)) {
fprintf(stderr, "ERROR: File %s has a record where naming convention is inconsistent with other files:\n", _fileNames[fileIdx].c_str());
record->print(stderr, true);
exit(1);
nameConventionWarning(record, _fileNames[fileIdx], " has a record where naming convention is inconsistent with other files:\n");
}
if (_allFilesHaveChrInChromNames == UNTESTED) {
......@@ -665,14 +668,10 @@ void ContextBase::testNameConventions(const Record *record) {
if (testChrVal == UNTESTED) {
_fileHasLeadingZeroInChromNames[fileIdx] = zeroVal ? YES : NO;
} else if ((testChrVal == YES && !zeroVal) || (testChrVal == NO && zeroVal)) {
fprintf(stderr, "ERROR: File %s has inconsistent naming convention (leading zero) for record:\n", _fileNames[fileIdx].c_str());
record->print(stderr, true);
exit(1);
nameConventionWarning(record, _fileNames[fileIdx], " has inconsistent naming convention (leading zero) for record:\n");
}
if ((_allFileHaveLeadingZeroInChromNames == YES && !zeroVal) || (_allFileHaveLeadingZeroInChromNames == NO && zeroVal)) {
fprintf(stderr, "ERROR: File %s has a record where naming convention (leading zero) is inconsistent with other files:\n", _fileNames[fileIdx].c_str());
record->print(stderr, true);
exit(1);
nameConventionWarning(record, _fileNames[fileIdx], " has a record where naming convention (leading zero) is inconsistent with other files:\n");
}
if (_allFileHaveLeadingZeroInChromNames == UNTESTED) {
......@@ -696,3 +695,15 @@ ContextBase::testType ContextBase::fileHasLeadingZeroInChromNames(int fileIdx) {
return iter->second;
}
void ContextBase::nameConventionWarning(const Record *record, const QuickString &filename, const QuickString &message)
{
_nameConventionWarningMsg = "***** WARNING: File ";
_nameConventionWarningMsg.append(filename);
_nameConventionWarningMsg.append(message);
record->print(_nameConventionWarningMsg);
_nameConventionWarningMsg.append("\n");
_nameConventionWarningTripped = true;
cerr << _nameConventionWarningMsg << endl;
}
......@@ -277,6 +277,12 @@ protected:
testType _allFilesHaveChrInChromNames;
testType _allFileHaveLeadingZeroInChromNames;
//Warning messages.
bool _nameConventionWarningTripped;
QuickString _nameConventionWarningMsg;
void nameConventionWarning(const Record *record, const QuickString &filename, const QuickString &message);
};
#endif /* CONTEXTBASE_H_ */
......@@ -74,9 +74,9 @@ rm obs
############################################################
echo " intersect.t05...\c"
echo \
"ERROR: File db1_noChr.bed has inconsistent naming convention for record:
"***** WARNING: File db1_noChr.bed has inconsistent naming convention for record:
2 50 80" > exp
$BT intersect -a q1_num.bed -b db1_noChr.bed -sorted 2>&1 > /dev/null | cat - > obs
$BT intersect -a q1_num.bed -b db1_noChr.bed -sorted 2>&1 > /dev/null | cat - | head -2 > obs
check obs exp
rm obs
......@@ -86,9 +86,9 @@ rm obs
############################################################
echo " intersect.t06...\c"
echo \
"ERROR: File db1_leadingZero.txt has a record where naming convention (leading zero) is inconsistent with other files:
"***** WARNING: File db1_leadingZero.txt has a record where naming convention (leading zero) is inconsistent with other files:
chr01 10 20" > exp
$BT intersect -a q1_num.bed -b db1_leadingZero.txt -sorted 2>&1 > /dev/null | cat - > obs
$BT intersect -a q1_num.bed -b db1_leadingZero.txt -sorted 2>&1 > /dev/null | head -2 > obs
check obs exp
rm obs
......
......@@ -551,9 +551,9 @@ rm exp obs
##################################################################
echo " intersect.t45...\c"
echo \
"ERROR: File nonamecheck_b.bed has a record where naming convention (leading zero) is inconsistent with other files:
"***** WARNING: File nonamecheck_b.bed has a record where naming convention (leading zero) is inconsistent with other files:
chr01 15 25" > exp
$BT intersect -a nonamecheck_a.bed -b nonamecheck_b.bed -sorted 2>&1 > /dev/null | cat - > obs
$BT intersect -a nonamecheck_a.bed -b nonamecheck_b.bed -sorted 2>&1 > /dev/null | cat - | head -2 > obs
check exp obs
rm exp obs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment