Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clustal-js

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clustal-js - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

dist/index.d.ts

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# v1.0.3
- Add generated typescript declarations to output
## v1.0.2

@@ -2,0 +7,0 @@

52

dist/index.js

@@ -1,29 +0,25 @@

import { parseBlocks, parseHeader, getFirstNonEmptyLine } from "./util";
export function parseIter(arr) {
const line = getFirstNonEmptyLine(arr);
if (!line) throw new Error("Empty file received");
const header = parseHeader(line);
const res = parseBlocks(arr);
if (res === undefined) throw new Error("No blocks parsed");
const alns = res.seqs.map((n, index) => ({
id: res.ids[index],
seq: n
}));
const {
consensus
} = res;
if (consensus.length != alns[0].seq.length) {
throw new Error(`Consensus length != sequence length. Con ${consensus.length} seq ${alns[0].seq.length}`);
}
return {
consensus,
alns,
header
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.parseIter = void 0;
const util_1 = require("./util");
function parseIter(arr) {
const line = util_1.getFirstNonEmptyLine(arr);
if (!line)
throw new Error("Empty file received");
const header = util_1.parseHeader(line);
const res = util_1.parseBlocks(arr);
if (res === undefined)
throw new Error("No blocks parsed");
const alns = res.seqs.map((n, index) => ({ id: res.ids[index], seq: n }));
const { consensus } = res;
if (consensus.length != alns[0].seq.length) {
throw new Error(`Consensus length != sequence length. Con ${consensus.length} seq ${alns[0].seq.length}`);
}
return { consensus, alns, header };
}
export function parse(contents) {
const iter = contents.split("\n")[Symbol.iterator]();
return parseIter(iter);
}
exports.parseIter = parseIter;
function parse(contents) {
const iter = contents.split("\n")[Symbol.iterator]();
return parseIter(iter);
}
exports.parse = parse;

@@ -1,80 +0,75 @@

export function parseVersion(line) {
const res = line.match(/\(?(\d+(\.\d+)+)\)?/);
return res && res.length > 1 ? res[1] : "";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseBlocks = exports.parseBlock = exports.getSeqBounds = exports.getFirstNonEmptyLine = exports.parseHeader = exports.parseVersion = void 0;
function parseVersion(line) {
const res = line.match(/\(?(\d+(\.\d+)+)\)?/);
return res && res.length > 1 ? res[1] : "";
}
export function parseHeader(info) {
const knownHeaders = ["CLUSTAL", "PROBCONS", "MUSCLE", "MSAPROBS", "Kalign"];
if (!knownHeaders.find(l => info.startsWith(l))) {
console.warn(`${info} is not a known CLUSTAL header: ${knownHeaders.join(",")}, proceeding but could indicate an issue`);
}
const version = parseVersion(info);
return {
info,
version
};
exports.parseVersion = parseVersion;
function parseHeader(info) {
const knownHeaders = ["CLUSTAL", "PROBCONS", "MUSCLE", "MSAPROBS", "Kalign"];
if (!knownHeaders.find((l) => info.startsWith(l))) {
console.warn(`${info} is not a known CLUSTAL header: ${knownHeaders.join(",")}, proceeding but could indicate an issue`);
}
const version = parseVersion(info);
return { info, version };
}
export function getFirstNonEmptyLine(arr) {
// There should be two blank lines after the header line
let line = arr.next();
while (!line.done && line.value.trim() === "") {
line = arr.next();
}
return line.value;
exports.parseHeader = parseHeader;
function getFirstNonEmptyLine(arr) {
// There should be two blank lines after the header line
let line = arr.next();
while (!line.done && line.value.trim() === "") {
line = arr.next();
}
return line.value;
}
export function getSeqBounds(line) {
const fields = line.split(/\s+/);
const temp = line.slice(fields[0].length);
const s = fields[0].length + temp.indexOf(fields[1]);
const e = s + fields[1].length;
return [s, e];
} // Use the first block to get the sequence identifiers
export function parseBlock(arr) {
let line = getFirstNonEmptyLine(arr);
const block = [];
let consensusLine = "";
if (!line) return undefined;
while (line) {
if (line[0] !== " ") block.push(line);else consensusLine = line;
line = arr.next().value;
}
const [start, end] = getSeqBounds(block[0]);
const fields = block.map(s => s.split(/\s+/));
const ids = fields.map(s => s[0]);
const seqs = block.map(s => s.slice(start, end));
let consensus = consensusLine.slice(start, end); // handle if the consensus trailing whitespace got trimmed
const remainder = seqs[0].length - consensus.length;
if (remainder) {
consensus += " ".repeat(remainder);
}
return {
ids,
seqs,
consensus
};
exports.getFirstNonEmptyLine = getFirstNonEmptyLine;
function getSeqBounds(line) {
const fields = line.split(/\s+/);
const temp = line.slice(fields[0].length);
const s = fields[0].length + temp.indexOf(fields[1]);
const e = s + fields[1].length;
return [s, e];
}
export function parseBlocks(arr) {
let block;
const res = parseBlock(arr);
if (res !== undefined) {
while (block = parseBlock(arr)) {
for (let i = 0; i < block.seqs.length; i++) {
res.seqs[i] += block.seqs[i];
}
res.consensus += block.consensus;
exports.getSeqBounds = getSeqBounds;
// Use the first block to get the sequence identifiers
function parseBlock(arr) {
let line = getFirstNonEmptyLine(arr);
const block = [];
let consensusLine = "";
if (!line)
return undefined;
while (line) {
if (line[0] !== " ")
block.push(line);
else
consensusLine = line;
line = arr.next().value;
}
}
return res;
}
const [start, end] = getSeqBounds(block[0]);
const fields = block.map((s) => s.split(/\s+/));
const ids = fields.map((s) => s[0]);
const seqs = block.map((s) => s.slice(start, end));
let consensus = consensusLine.slice(start, end);
// handle if the consensus trailing whitespace got trimmed
const remainder = seqs[0].length - consensus.length;
if (remainder) {
consensus += " ".repeat(remainder);
}
return { ids, seqs, consensus };
}
exports.parseBlock = parseBlock;
function parseBlocks(arr) {
let block;
const res = parseBlock(arr);
if (res !== undefined) {
while ((block = parseBlock(arr))) {
for (let i = 0; i < block.seqs.length; i++) {
res.seqs[i] += block.seqs[i];
}
res.consensus += block.consensus;
}
}
return res;
}
exports.parseBlocks = parseBlocks;
{
"name": "clustal-js",
"version": "1.0.2",
"version": "1.0.3",
"main": "dist/index.js",
"repository": "cmdcolin/clustal-js",
"files": [

@@ -6,0 +7,0 @@ "dist"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc