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

p2s_mapper

v1.2.0

Published

Map a transcript's translation onto a protein structure: alignment, coordinates, chain choice, SIFTS, and the AlphaFold and PDBe lookups that find the structure

Readme

p2s_mapper

Map a transcript's translation onto a protein structure: the pairwise alignment between them, the coordinate maps that alignment implies, which chain of the structure is the gene's product, SIFTS residue numbering, and the AlphaFold, PDBe and UniProt lookups that find a structure to map in the first place.

Extracted from jbrowse-plugin-protein3d, which is where the measurements behind the scoring rules were made. The package has no React, no JBrowse and no Mol* dependency: a loaded Mol* model reaches it through narrow structural interfaces, and g2p_mapper is the only runtime dependency.

Install

npm install p2s_mapper

Coordinate conventions

One residue has up to four numbers, and mixing them is the off-by-one class of bug this package exists to prevent. Every stored or computed coordinate is a 0-based position: an index into the ungapped structure sequence or the ungapped transcript sequence, which is the one numbering that is dense and zero-based whatever the file. coordinates.ts brands the three internal spaces — structure position, transcript position, alignment column — so the compiler rejects mixing them. Two conversions leave that space, and each has one door. Mol* is addressed by label_seq_id, which is position + 1 only for a file carrying entity_poly_seq or SEQRES; a SEQRES-less PDB numbers its observed residues by author numbering and leaves holes at unobserved loops, so Entity.seqIds carries the real ids and every crossing goes through toLabelSeqIds, rangeToLabelSeqIds or makeLabelSeqIdIndex. The user is shown auth_seq_id, the depositors' numbering, which is what papers and UniProt cite (1TUP position 154 reads 248) and what Mol*'s own hover shows; Entity.authSeqIds carries it and it is display-only. UniProt positions are 1-based, and pdbUniProtMapping converts them with SIFTS rather than assuming any offset.

Exports

Alignment

runLocalAlignment, scoredAlignment, needlemanWunsch, smithWaterman, selfScore, alignmentTooLarge, MAX_ALIGNMENT_CELLS — Smith-Waterman and Needleman-Wunsch over BLOSUM62, with affine gaps and a packed traceback.

PairwiseAlignment, transcriptAlignedSeq, structureAlignedSeq, alignmentLength, pairwiseAlignmentProblem, pairwiseAlignmentSequenceProblem, mappedStructureIdentity, unmapStructurePositions — the two-row alignment, whose row order is a contract: row 0 is the transcript, row 1 is the structure. Read it through the accessors, not by index.

alignmentQuality, isLowSimilarity, describeAlignmentQuality, describeTranscriptCoverage, describeCoveredRange — identity over the shorter sequence is what separates a real match from a chance local alignment; local identity alone does not.

AlignmentAlgorithm, coerceAlignmentAlgorithm, ALIGNMENT_ALGORITHM_LABELS.

Coordinates

makeCoordinateMapper, CoordinateMapper, transcriptRangeToStructureRange, structurePos, transcriptPos, alignmentCol — every conversion built once from an alignment, branded by space.

structureSeqVsTranscriptSeqMap, structurePositionToAlignmentMap, transcriptPositionToAlignmentMap, invertMap, codonGenomeSpan, stripStopCodon, stripAllStopCodons.

Chain choice

chooseMappedEntity, alignTranscriptToEntity, explainedFraction, interactionMatchesMappedEntity — which polymer entity is the transcript's product, ranked by identical residues over the shorter of the two sequences. A raw match count picks the large partner of every bound peptide, and the alignment score does not separate them either.

extractEntities, extractStructureSequences, entityLabel, residueNumber, residueRangeToPositions, fillAuthSeqIds, oneLetterSequence, toLabelSeqIds, rangeToLabelSeqIds, makeLabelSeqIdIndex — read a loaded Mol* model through a structural interface. Read sequence.code, never sequence.label: label spells MSE, TPO and ACE by component id, so the string outgrows seqId and every later position addresses the wrong residue.

extractPerResidueConfidence, looksLikePlddt — AlphaFold's pLDDT out of the B-factor column, keyed by label_seq_id because the hierarchy holds only observed residues.

classifyIsoforms, selectBestTranscript, pickStructureSequence — rank plain { id, seq } isoform records against a chain.

SIFTS

fetchUniProtStructureMappings, parseUniProtStructureMappings, pdbeSiftsUrl, chooseUniProtMappingForEntity, makeUniProtPositionMap, identityUniProtPositionMap, fusionPartnerPositions — the authoritative UniProt ↔ structure alignment. fusionPartnerPositions unmaps the residues SIFTS gives another protein on a fusion construct, which local alignment otherwise bridges (2RH1 scatters 33 receptor residues onto T4 lysozyme).

toAuthorRange, segmentsForAccession — the author-numbered range a UniProt range is cited by. Haemoglobin numbers from the mature protein, so author residue 1 is UniProt residue 2.

Structure sources

fetchAlphaFoldModels, parseAlphaFoldModels, pickAlphaFoldModel — asked rather than derived: a protein past AlphaFold's length cap has no F1 model at all, and the model version moves.

fetchExperimentalStructures, parseExperimentalStructures — 3D-Beacons' experimental entries, PDBe only, because SASBDB's scattering fits file under the same category with near-full coverage and no residue mapping.

pdbeBestStructuresUrl, parseBestStructures, isPdbId, pdbeEntryMoleculesUrl, parseEntryMolecules, searchUniProtEntries, buildGeneNameQuery, isRecognizedDatabaseId, buildUniProtXrefQuery, getDbIdLabel, stripTrailingVersion.

Every request takes its fetch from the call — { fetch?: typeof fetch, signal? }, defaulting to globalThis.fetch — so a host can hand in an instrumented one and a test can hand in a double.

Urls and formats

getPdbStructureUrl, getAlphaFoldStructureUrl, resolveStructureUrl, getPdbIdFromUrl, getUniprotIdFromAlphaFoldTarget, getStructureUrlFromTarget, getConfidenceUrlFromTarget, structureDisplayLabel, uniprotGffUrl, uniprotFastaUrl, uniprotEntryUrl, rcsbEntryUrl.

structureFormatFromContent, structureFormatFromName, structureFileExtension, isBinaryStructureUrl — which parser a structure needs, sniffed from content rather than a filename. Getting it wrong fails asymmetrically: PDB read as mmCIF throws, while mmCIF read as PDB succeeds and yields a model with thousands of misread atoms and zero polymer entities.

caCoordsToPdb, hasValidCaCoords — a PDB file from Foldseek Cα coordinates.

rawfetch, myfetch, jsonfetch, httpError, HttpError, isDefinitiveFailure, networkError, abortError, timeout, FetchOptions. A failed response throws an HttpError carrying its status, and isDefinitiveFailure is true for a 4xx — the server understood and declined, so retrying repeats the answer. fetchUniProtStructureMappings uses it: PDBe answers 404 for an entry it has no UniProt mapping for at all.

License

MIT