JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q27228F
  • License MIT

Module for parsing files in FASTA-format

Package Exports

  • ez-fasta

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ez-fasta) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ez-fasta

Модуль для работы с данными в fasta-формате.

Installation

Для работы требуется node.

npm install ez-fasta

Usage example

const fasta = require('ez-fasta');

fasta
  .read('./pathTo.fasta')
  .then(data => console.log(data))

Хорошо работает с async/await:

async function analyze(folder) {
  const samples = await fasta.readFromFolder(folder);
  const reference = await fasta.readSingle('./path/to/reference.fa');
  const dataset = [reference, ...samples];

  // Do your stuff
  // align(dataset)

  for (sample of samples) {
    // Do your stuff
    console.log(`${sample.label} - ${sample.sequence.length} bp`);
  }

  return;
}

read(path) - читает файл (fasta) и возвращает промис для массива из объектов вида [... { label, sequence }].

readSingle(path) - прочитает только первую последовательность из fasta-файла (даже если их там несколько), возвращает промис с объектом { label, sequence }.

readFromFolder(path) - читает все файлы из папки и возвращает промис для массива из объектов вида [... { label, sequence }]. Внимание! Эта функция не делает никаких предварительных проверок на валидность входящих файлов и читает всё подряд.

write(data, path) - создаёт корректный fasta-файл из объекта { label, sequence } или из массива объектов [... { label, sequence }].


Take a look at mtget, a tiny nodejs program, if you need to download fasta sequences from GenBank.