Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
<div class="container-fluid">
<h1>CpG tracker</h1>
<div class="row">
<div class="col-md-4">
<h2>Prediction models</h2>
<cpg-form @checkModel="updateModel" />
</div>
<div class="col-md-8">
<h2>Sequences</h2>
<sequence-selector ref="sequenceSelector" @analyse="startAnalysis" />
</div>
</div>
<div class="alert alert-danger" v-if="serverError">{{ serverError }}</div>
<div v-if="waitError">
<hr />
<div class="alert alert-danger">
<div class="row">
<p class="col-10">
Waiting for results took too long.
</p>
<div class="col-2">
<button class="btn btn-primary btn-block" @click="waitForResult(analysisId)">
<span class="fa fa-refresh"></span> Keep waiting
</button>
</div>
</div>
</div>
</div>
<b-tabs v-if="finishedAnalysis.length > 0">
<b-tab v-for="(analysis, i) of finishedAnalysis" :key="analysis.payload.id" :title="'Results ' + (i + 1)">
<br />
<results :analysis-info="analysis.payload" :download-token="analysis.downloadToken">
<b-btn variant="danger" class="float-right" @click="closeResults(analysis.payload)">
Close tab
</b-btn>
</results>
</b-tab>
</b-tabs>
<hr />
<div class="card bg-light">
<div class="card-body">
CpG analyser Tokai alg #TODO
</div>
</div>
</div>
</template>
<script type="text/javascript">
import SequenceSelector from '@/components/sequence/sequence-selector'
import BatchWatcher from '@/services/batch-watcher'
import CpgForm from './cpg-form'
import Results from './cpg-results'
export default {
data() {
return {
minWindowSize: 200,
minGcPercentage: 0.5,
minObservedToExpectedCpG: 0.6,
minIslandMergeGap: 100,
firstNucleotide: 'C',
secondNucleotide: 'G',
config: {},
finishedAnalysis: [],
analysisId: null,
waiting: false,
waitError: false,
serverError: null,
}
},
methods: {
closeResults(analysis) {
this.finishedAnalysis = this.finishedAnalysis.filter(info => {
return info.payload.id !== analysis.id
})
},
waitForResult(analysisId) {
this.waitError = false
this.waiting = true
var bw = new BatchWatcher(this.$http)
this.$store.commit('addWork', { key: analysisId, title: 'CpG analysis' })
return bw
.wait('analyse/cpg/' + analysisId + '/analysis')
.then(response => {
this.finishedAnalysis.push(response.data)
})
.finally(() => {
this.$store.commit('workDone', analysisId)
this.waiting = false
})
},
updateModel(value, type) {
if (type === 'minWindowSize') {
this.minWindowSize = value;
} else if (type === 'minGcPercentage') {
this.minGcPercentage = value;
} else if (type === 'minObservedToExpectedCpG') {
this.minObservedToExpectedCpG = value;
} else if (type === 'minIslandMergeGap') {
this.minIslandMergeGap = value;
} else if (type === 'firstNucleotide') {
this.firstNucleotide = value;
} else if (type === 'secondNucleotide') {
this.secondNucleotide = value;
}
},
startAnalysis(sequence, callback) {
this.$http
.post('analyse/cpg', {
minWindowSize: this.minWindowSize,
minGcPercentage: this.minGcPercentage,
minObservedToExpectedCpG: this.minObservedToExpectedCpG,
minIslandMergeGap: this.minIslandMergeGap,
firstNucleotide: this.firstNucleotide,
secondNucleotide: this.secondNucleotide,
sequence: sequence.id,
tags: sequence.tags,
})
.then(response => {
const item = response.data.payload
this.serverError = null
this.analysisId = item.id
return this.waitForResult(item.id)
})
.then(() => {
callback()
})
.catch(error => {
this.serverError = error?.response?.data?.message
callback('FAILED')
})
},
clearAnalysis() {
this.cpgAnalysis = []
},
},
components: {
'sequence-selector': SequenceSelector,
results: Results,
'cpg-form': CpgForm,
},
}
</script>