npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lipme/ts-biofiledetector

v0.1.0

Published

A set of function to detect bioinformatics file types (bam, gff3, bed, vcf, tsv, bigwig)

Readme

TS-BIOFILEDETECTOR

Overview

A set of function to predict file formats

Formats included:

Installation

npm i @lipme/ts-biofiledetector

Requires Node.js 18 or later.

Usage

import { getFileFormat } from "@lipme/ts-biofiledetector";

const result = await getFileFormat("path/to/file");

Compressed files (gzip, bzip2, xz) are detected from their content, whatever their extension.

The first 1000 lines are read once to select the candidate formats, so a file is usually read in full only once.

Each detector can also be called on its own (isFasta, isGff3, isVcf, isBed, isTsv, isBam, isBigwig); it returns the result, or null when the file is not in that format.

Output

All results share this shape:

{
  format: "fasta|gff3|bed|vcf|tsv|bam|bigwig|unknown",
  valid: true|false,          // false when there are errors
  errors?: [ issue ],         // first 100 errors only
  errorCount?: number,        // total number of errors
  warnings?: [ issue ],       // first 100 warnings only
  warningCount?: number,      // total number of warnings
  metadata: { ... }           // format specific, see below
}

where an issue is:

{
  code: "INVALID_LINE",       // stable identifier, see the list below
  message: "Not a BED line",  // human readable
  line?: 12,                  // 1-based line number, when about one line
  content?: "chr1 abc 20"     // the line, cut to 200 characters
}

| Format | Error codes | Warning codes | | --- | --- | --- | | Fasta | DUPLICATE_ID, UNKNOWN_CHARACTERS | | | GFF3 | INVALID_LINE, INVALID_ATTRIBUTE, EMPTY_ATTRIBUTE | FASTA_SECTION (lines after ##FASTA are not parsed) | | BED | INVALID_LINE, START_AFTER_END, MIXED_COLUMN_COUNTS | TRAILING_WHITESPACE, MIXED_SEPARATORS | | VCF | INVALID_LINE, HEADER_AFTER_DATA | | | TSV | WRONG_FIELD_COUNT | | | BAM | TRUNCATED_HEADER, CORRUPTED_HEADER | |

Format specific results:

  • Fasta
{
  format: "fasta",
  valid: true|false,
  metadata: {
    type: "dna|protein",
    category: "sequence",
    seqids: ['list','of','seqids'],
    alignment: true|false, // true if >= 2 sequences, all of the same length, with gaps ('-' or '.')
    alignmentLength?: "alignmentLength", // only when alignment is true
  }
}
  • GFF3
{
    format: "gff3",
    valid: true|false,
    metadata: {
    type: "annotation|alignment|interproscan",
    category: "annotation|alignment|protein_match",
    seqids: ['list','of','seqids'],
    features: ['list', 'of', 'features'],
    attributes: {'list' : 'cardinality', 'of' : 'cardinality', 'attributes' : 'cardinality'}
  }
}
  • BED
{
  format: "bed",
  valid: true|false,
  metadata: {
    type: "bed3|...|bed12", // "bed" when the number of columns varies
    category: "annotation",
    seqids: ['list','of','seqids'],
    columns: numberOfColumns, // list of the numbers of columns when it varies
    withBrowser: true|false, //browser line found
    withTrack: true|false, //track line found
  }
}
  • VCF
{
  format: "vcf",
  valid: true|false,
  metadata: {
    type: "VCFversion",
    category: "polymorphism",
    seqids: ['list','of','seqids'],
    samples: ['list','of','samples'], // empty for a sites-only VCF (no FORMAT/sample columns)
    fields: {'INFO', 'and', 'FORMAT', 'metadata'}
    }
}
  • TSV
{
  format: "tsv",
  valid: true|false,
  metadata: {
    type: "unknown|orthofinder|interproscan|nicknames|paf|dge",
    category: "table|alignment", // alignment for paf
    columns: numberOfColumns,
    lines: numberOfLines,
    explicitHeader: true|false, //true if first line stars with '#'
    header: ['list','of','field','names'],
    }
}
  • BAM
{
  format: "bam",
  valid: true|false,
  metadata: {
    type: "alignment",
    category: "alignment",
    seqids: ['list', 'of', 'seqids'], // reference names from the binary header
    programs: ['list', 'of', 'programs']  //@PG lines
  }
}
  • BigWig
{
  format: "bigwig",
  valid: true,
  metadata: {
    type: "quantitative",
    category: "quantitative",
    seqids: ['list', 'of', 'seqids'], // chromosomes
    version: 'bigwigVersion'
  }
}

Development

npm ci
npm run typecheck   # tsc
npm run lint        # ESLint
npm test            # Jest, with snapshots in tests/__snapshots__ (update them with `npx jest -u`)
npm run build       # tsup, to dist/
npm run test:dist   # loads dist/ through ESM import and CommonJS require

The same steps run in GitLab CI (.gitlab-ci.yml). See CHANGELOG.md for the changes between versions.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Contact

For questions or feedback, please open an issue or contact us at [email protected]