|
@@ -218,6 +218,7 @@ const makeRefSeqFromReg = async (
|
|
|
await fs.promises.mkdir(tmpDir)
|
|
await fs.promises.mkdir(tmpDir)
|
|
|
const createdFiles: string[] = []
|
|
const createdFiles: string[] = []
|
|
|
let counter = 0
|
|
let counter = 0
|
|
|
|
|
+
|
|
|
for (const jsiFile of jsiFiles) {
|
|
for (const jsiFile of jsiFiles) {
|
|
|
console.log('reading ' + jsiFile)
|
|
console.log('reading ' + jsiFile)
|
|
|
for await (const line of line$(jsiFile)) {
|
|
for await (const line of line$(jsiFile)) {
|
|
@@ -228,8 +229,12 @@ const makeRefSeqFromReg = async (
|
|
|
try {
|
|
try {
|
|
|
const file = path.join(tmpDir, res?.version || res.accession + '.fa')
|
|
const file = path.join(tmpDir, res?.version || res.accession + '.fa')
|
|
|
if (!createdFiles.includes(file)) {
|
|
if (!createdFiles.includes(file)) {
|
|
|
|
|
+ if (createdFiles.length === 0) if (fs.existsSync(distFile)) await fs.promises.rm(distFile)
|
|
|
await writeSequence(res?.version || res.accession, res?.sequence, file)
|
|
await writeSequence(res?.version || res.accession, res?.sequence, file)
|
|
|
createdFiles.push(file)
|
|
createdFiles.push(file)
|
|
|
|
|
+ const tmp = await fs.promises.readFile(file)
|
|
|
|
|
+ await fs.promises.appendFile(distFile, tmp.toString() + '\n')
|
|
|
|
|
+ await fs.promises.rm(file)
|
|
|
counter++
|
|
counter++
|
|
|
if (counter%100 === 0) console.log('Already ' + counter + ' sequence parsed')
|
|
if (counter%100 === 0) console.log('Already ' + counter + ' sequence parsed')
|
|
|
}
|
|
}
|
|
@@ -242,13 +247,8 @@ const makeRefSeqFromReg = async (
|
|
|
}
|
|
}
|
|
|
if (limit) if (counter === limit) break
|
|
if (limit) if (counter === limit) break
|
|
|
}
|
|
}
|
|
|
- console.log(createdFiles.length + ' sequences')
|
|
|
|
|
|
|
+ console.log(createdFiles.length + ' sequences were extracted')
|
|
|
|
|
|
|
|
- if (fs.existsSync(distFile)) await fs.promises.rm(distFile)
|
|
|
|
|
- for (const createdFile of createdFiles) {
|
|
|
|
|
- const tmp = await fs.promises.readFile(createdFile)
|
|
|
|
|
- await fs.promises.appendFile(distFile, tmp.toString() + '\n')
|
|
|
|
|
- }
|
|
|
|
|
await fs.promises.rm(tmpDir, {recursive: true})
|
|
await fs.promises.rm(tmpDir, {recursive: true})
|
|
|
await async_exec('bwa', ['index', distFile], () => console.log)
|
|
await async_exec('bwa', ['index', distFile], () => console.log)
|
|
|
}
|
|
}
|