forked from bridgedb/data
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a script to generate gdb.config content
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | ||
} | ||
} | ||
} | ||
} | ||
} |