|
|
@@ -77,15 +77,30 @@ const clusterSam = (
|
|
|
[key: string]: string[]
|
|
|
}
|
|
|
let byReads: byReads = {}
|
|
|
-
|
|
|
+ interface posObj {
|
|
|
+ [key: string]: string
|
|
|
+ }
|
|
|
+ interface posAll {
|
|
|
+ [key: string]: posObj
|
|
|
+ }
|
|
|
+ let posAll: posAll = {}
|
|
|
Object
|
|
|
.keys(byContigs)
|
|
|
.map(name => {
|
|
|
let cluster = 0
|
|
|
+ let firstPos = 0
|
|
|
byContigs[name]
|
|
|
.sort((a, b) => a.position - b.position)
|
|
|
.map((e, i, a) => {
|
|
|
- cluster = Math.abs(e.position - a[i-1]?.position) > threshold ? cluster + 1 : cluster
|
|
|
+ if(i === 0) {
|
|
|
+ firstPos = e.position
|
|
|
+ }
|
|
|
+ if (Math.abs(e.position - a[i-1]?.position) > threshold) {
|
|
|
+ posAll[name][String(cluster)] = firstPos + '-' + a[i-1]?.position
|
|
|
+ cluster = cluster + 1
|
|
|
+ firstPos = e.position
|
|
|
+ }
|
|
|
+ // cluster = Math.abs(e.position - a[i-1]?.position) > threshold ? cluster + 1 : cluster
|
|
|
const clutserName = cluster + '@' + name
|
|
|
byReads[e.rname] = Array.isArray(byReads[e.rname]) ? [... new Set([...byReads[e.rname], clutserName])] : [clutserName]
|
|
|
})
|
|
|
@@ -96,7 +111,10 @@ const clusterSam = (
|
|
|
}
|
|
|
let byClusters: byClusters = {}
|
|
|
Object.keys(byReads).map(rname => {
|
|
|
- const tmpClusterName = byReads[rname].sort().join('<--->')
|
|
|
+ const tmpClusterName = byReads[rname].sort().map(e => {
|
|
|
+ const splited = e.split(/@/)
|
|
|
+ return splited[1] + ':' + posAll[splited[1]][splited[0]] + '(' + splited[0] + ')'
|
|
|
+ }).join('<--->')
|
|
|
byClusters[tmpClusterName] = Array.isArray(byClusters[tmpClusterName]) ? [... new Set([...byClusters[tmpClusterName], rname])] : [rname]
|
|
|
})
|
|
|
|