|
|
@@ -12,12 +12,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
};
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
-exports.asyncReadSmallFasta = exports.asyncReadFasta = void 0;
|
|
|
+exports.selectFasta = exports.asyncReadSmallFasta = exports.asyncReadFasta = void 0;
|
|
|
const child_process_1 = require("child_process");
|
|
|
const fs_1 = __importDefault(require("fs"));
|
|
|
const zlib = require('zlib');
|
|
|
const readline = require('readline');
|
|
|
const Papa = require('papaparse');
|
|
|
+const async_exec = (prog, args, onData) => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const child = (0, child_process_1.spawn)(prog, args, { shell: true });
|
|
|
+ child.stdout.on('data', data => onData(data.toString().trim()));
|
|
|
+ child.stderr.on('data', data => onData(data.toString().trim()));
|
|
|
+ child.on('error', err => reject(err));
|
|
|
+ child.on('exit', code => resolve(code));
|
|
|
+ });
|
|
|
+};
|
|
|
// Read fasta/fa/fna
|
|
|
const asyncReadSmallFasta = (path) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
@@ -126,3 +135,11 @@ const asyncReadFasta = (path, sequences) => {
|
|
|
}));
|
|
|
};
|
|
|
exports.asyncReadFasta = asyncReadFasta;
|
|
|
+const selectFasta = (path, name, out) => {
|
|
|
+ return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
+ if (!Array.isArray(name))
|
|
|
+ name = [name];
|
|
|
+ yield async_exec('samtools', ['faidx', path, ...name, '>', out], console.log);
|
|
|
+ }));
|
|
|
+};
|
|
|
+exports.selectFasta = selectFasta;
|