Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions gortools/src/main/scala/gorsat/Utilities/gorsatUtilities.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,20 @@ object Utilities {
// return an iterator that only delivers the header defined with -dh.
val header = stringValueOfOption(args, "-dh")
val headerCols = header.split(",")
if (headerCols.length < 2 || headerCols(0).isEmpty || headerCols(1).isEmpty) {
throw new GorParsingException("-dh requires at least 2 non-empty comma-separated values")
}
val inputSource = RowListIterator(List())
if (isNor) inputSource.setHeader(HEADER_PREFIX + headerCols.mkString("\t")) else inputSource.setHeader(headerCols.mkString("\t"))
InputSourceParsingResult(inputSource, header, isNorContext = false)
if (isNor) {
if (headerCols.length < 1 || headerCols(0).isEmpty) {
throw new GorParsingException("For NOR -dh requires at least 1 non-empty value")
}
inputSource.setHeader(HEADER_PREFIX + headerCols.mkString("\t"))
} else {
if (headerCols.length < 2 || headerCols(0).isEmpty || headerCols(1).isEmpty) {
throw new GorParsingException("For GOR -dh requires at least 2 non-empty comma-separated values")
}
inputSource.setHeader(headerCols.mkString("\t"))
}

InputSourceParsingResult(inputSource, header, isNorContext = isNor)
}
}

Expand Down
3 changes: 2 additions & 1 deletion gortools/src/test/java/gorsat/UTestNorif.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ public static Collection<Object[]> data() throws IOException {
{"Nested query started with norif", "norif <(nor " + testTsvFile1 + ")",
expectedHeader + "chrN\t0\tA\t1\tA\n", null},
{"Invalid file path", "norif -dh col1,col2 not_exists.tsv", HEADER_PREFIX+ "col1\tcol2\n", null},
{"Invalid file path, single col", "norif -dh col1 not_exists.tsv", HEADER_PREFIX+ "col1\n", null},
{"Invalid file path missing -dh", "norif not_exists.tsv", null, GorParsingException.class},
{"Empty file missing -dh", "norif " + testEmptyFile, null, GorParsingException.class},
{"Invalid file path with invalid -dh value", "norif -dh col1 not_exists.tsv", null, GorParsingException.class},
{"Invalid file path with invalid -dh value", "norif not_exists.tsv -dh ", null, GorParsingException.class},
{"Both invalid and valid file path", "norif " + testTsvFile1 + " not_exists.tsv",
expectedHeader + "chrN\t0\tA\t1\tA\n", null},
});
Expand Down
Loading