Skip to content

Commit

Permalink
Collapses input data for "coord" mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mikessh committed Dec 4, 2014
1 parent bb2294e commit 8d532b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
23 changes: 18 additions & 5 deletions src/main/groovy/es/unav/oncofuse/legacy/Oncofuse.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ switch (inputType) {
GParsPool.withPool THREADS, {
inputData.eachParallel { line ->
line = line.split("\t")
// Sort reads
// Here we collapse reads
try {
int type = Integer.parseInt(line[6])
String chrom1 = line[0], chrom2 = line[3]
Expand Down Expand Up @@ -328,10 +328,23 @@ switch (inputType) {
break

case 'coord':
def coordMap = new HashMap<String, int[]>()
def inputFile = new File(inputFileName)
inputFile.eachLine { line ->
if (!line.startsWith("#"))
inputData.add([line.split("\t").collect { it.trim() }, inputFileName, -1, -1].flatten().join("\t"))
inputFile.splitEachLine("\t") { List<String> splitLine ->
if (!splitLine[0].startsWith("#")) {
def signature = splitLine[0..4].join("\t")
def counters = coordMap[signature]
if (counters == null) {
coordMap.put(signature, counters = new int[2])
}
if (splitLine.size() > 6) {
counters[0] += splitLine[5].toInteger()
counters[1] += splitLine[6].toInteger()
}
}
}
coordMap.each {
inputData.add(it.key + "\t$inputFileName\t" + it.value.collect().join("\t"))
}
break

Expand All @@ -354,7 +367,7 @@ int ff = 0
int m1 = 0, m2 = 0, m3 = 0
inputData.each { line ->
j++
def splitLine = line.split("\t")
def splitLine = line.split("\t").collect { it.trim() }
def coord5 = Integer.parseInt(splitLine[1]), coord3 = Integer.parseInt(splitLine[3])
def tissue = splitLine[4].toUpperCase(), sample = splitLine[5]
def nSpan = splitLine[6].toInteger(), nEncomp = splitLine[7].toInteger()
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/example/example_coord.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Run java -Xmx1G -jar Oncofuse.jar example_coord.txt coord - out.txt
chr22 23632742 chr9 133607147 HEM
#chr1 coord1 chr2 coord2 tissue spanning encompassing
chr22 23632742 chr9 133607147 HEM 1 2
chr22 23632742 chr9 133607147 HEM 0 2
chr22 23632742 chr9 133607147 HEM

0 comments on commit 8d532b9

Please sign in to comment.