-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathUTILS.groovy
38 lines (35 loc) · 1.34 KB
/
UTILS.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Helper functions for pipeline tests
class UTILS {
// Function to remove Nextflow version from software_versions.yml
public static String removeNextflowVersion(outputDir) {
def softwareVersions = path("$outputDir/pipeline_info/software_versions.yml").yaml
if (softwareVersions.containsKey("Workflow")) {
softwareVersions.Workflow.remove("Nextflow")
}
return softwareVersions
}
// Function to filter lines from a file and return a new file
public static File filterLines(String inFilePath, int linesToSkip) {
if (linesToSkip >= 0) {
File inputFile = new File(inFilePath)
File outputFile = new File(inFilePath + ".filtered")
def lineCount = 0
inputFile.eachLine { line ->
lineCount++
if (lineCount > linesToSkip) {
outputFile.append(line + '\n')
}
}
return outputFile
} else {
File inputFile = new File(inFilePath)
File outputFile = new File(inFilePath + ".filtered")
def lines = inputFile.readLines()
def totalLines = lines.size()
lines.take(totalLines + linesToSkip).each { line ->
outputFile.append(line + '\n')
}
return outputFile
}
}
}