Skip to content

Commit

Permalink
Added a script to generate gdb.config content
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Sep 3, 2021
1 parent 64061ea commit 2f4e787
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions makeGDBconfig.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2021 Egon Willighagen
// License: MIT

import groovy.json.JsonSlurper

templateFile = "gene_database/template.md"

// create the GDB config file content
lines = new File(templateFile).readLines()
lines.each { String line ->
if (line.startsWith("<files>")) {
def instruction = new XmlSlurper().parseText(line)
def input = instruction.text()
def jsonSlurper = new JsonSlurper()
fileContents = new File(input).text
new File("${input}.config").withWriter('utf-8') { writer ->
def data = jsonSlurper.parseText(fileContents)
data.mappingFiles.each { mappingFile ->
if (data.type == "Species") {
if (mappingFile.species == "Human Coronaviruses") { // exception
writer.writeLine "*\t${mappingFile.file}"
} else {
writer.writeLine "${mappingFile.species}\t${mappingFile.file}"
}
} else {
writer.writeLine "*\t${mappingFile.file}"
}
}
}
}
}

0 comments on commit 2f4e787

Please sign in to comment.