https://github.com/flora-phenotype-ontology/flopoontology
Tip revision: cfb699302816405d6a7775ff377aaf5f05b510aa authored by Robert Hoehndorf on 06 September 2019, 01:20:44 UTC
FLOPO BioHackathon 2019 release
FLOPO BioHackathon 2019 release
Tip revision: cfb6993
MakeFuncInput.groovy
// arg 0: phenotype file; arg 1: environment file; arg 2: output dir
def pmap = [:].withDefault { new TreeSet() }
new File(args[0]).splitEachLine("\t") { line -> // the phenotypes
def taxon = line[1]
def anno = line[2]
pmap[anno].add(taxon)
}
def emap = [:].withDefault { new TreeSet() }
new File(args[1]).splitEachLine("\t") { line -> // environment
def taxon = line[0]
def anno = line[2]
emap[taxon].add(anno)
}
def taxon2count = [:]
def count = 0
emap.keySet().each { taxon ->
taxon2count[taxon] = count
count += 1
}
pmap.each { ppo, tset ->
def cppo = ppo.replaceAll("<http://phenomebrowser.net/plant-phenotype.owl#","").replaceAll(">","")
def fout = new PrintWriter(new BufferedWriter(new FileWriter(args[2]+"/"+cppo)))
emap.each { taxon, envo ->
if (taxon in tset) {
envo.each { env ->
fout.println("TAXON"+taxon2count[taxon]+"\t$env\t1")
}
} else {
envo.each { env ->
fout.println("TAXON"+taxon2count[taxon]+"\t$env\t0")
}
}
}
fout.flush()
fout.close()
}