formInline: {
sequence: '',
database: '',
evalue: '-evalue 1.0e-5 -num_alignments 10 -max_hsps 10',
blastType: ''
},
onSubmit () {
this.$refs.blastForm.validate((valid) => {
if (valid) {
const formData = new FormData()
for (var key in this.formInline) {
formData.append(key, this.formInline[key])
}
this.showProcess = true
request.post('/test', formData).then(
(reponse) => {
this.reponseData = reponse.data
this.showProcess = false
}
)
} else {
return false
}
})
}
在渲染序列比对情况时候,遇到对不齐的情况;主要是由于没有使用等宽字体
props: {
reponseData: {
default: () => {
return [{
query: 'CYP78A7',
queryLength: '559',
alignments: []
}]
}
}
computed: {
ValidateReponse () {
var newDataArray = []
this.reponseData.forEach((item) => {
var queryName = item.query
var queryLength = item.queryLength
var summaryTable = []
var singleTable = []
var AlignmentIf = ''
if (item.alignments.length > 0) {
AlignmentIf = true
item.alignments.forEach((subject, index) => {
summaryTable.push(
{
id: index + 1,
subjectName: subject.subjectName,
score: subject.score,
evalue: subject.eValue,
length: subject.subjectLength,
identities: subject.identities,
pairSequence: subject.pairSequence
}
)
singleTable.push([{
id: index + 1,
subjectName: subject.subjectName,
score: subject.score,
evalue: subject.eValue,
length: subject.subjectLength,
identities: subject.identities,
pairSequence: subject.pairSequence
}])
})
} else {
AlignmentIf = false
}
newDataArray.push({
queryName,
queryLength,
summaryTable,
AlignmentIf,
singleTable
})
})
return newDataArray
}
}
3.1创建两个临时文件,用于存储序列信息和blast运行结果
var tmp = require('tmp')
var queryFile = tmp.fileSync()
var BlastOutFile = tmp.fileSync()
//程序结束后,可以选择删除临时文件;或系统自动处理
BlastOutFile.removeCallback()
queryFile.removeCallback()
var callfile = require('child_process')
callfile.execFile(
'使用系统脚本的绝对路径',
[
queryFile.name,
BlastOutFile.name,
req.body.blastType,
req.body.database,
req.body.evalue
], (error, stdout, stderr) => {
if (error) {
console.log(error)
rep.send('error')
return
}
//读取blast结果
BlastText = fs.readFileSync(BlastOutFile.name, 'utf-8')
//解析blast outfmt 0 格式文件
BlastJson = parseBlastText(BlastText)
BlastOutFile.removeCallback()
queryFile.removeCallback()
rep.send(BlastJson)
})