clustal-js 1.0.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/README.md +99 -3
- package/package.json +13 -23
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -25
- package/dist/types.d.ts +0 -18
- package/dist/types.js +0 -2
- package/dist/util.d.ts +0 -7
- package/dist/util.js +0 -75
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
This parses clustal output format
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
## Usage
|
|
9
8
|
|
|
10
|
-
```
|
|
11
|
-
import {parse} from '
|
|
9
|
+
```typescript
|
|
10
|
+
import { parse } from 'clustal-js'
|
|
12
11
|
const file = fs.readFileSync('test.aln', 'utf8')
|
|
13
12
|
const ret = parse(file)
|
|
14
13
|
```
|
|
@@ -57,6 +56,103 @@ Output
|
|
|
57
56
|
version: '1.2.4' } }
|
|
58
57
|
```
|
|
59
58
|
|
|
59
|
+
### Parse pairwise outputs
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { parsePairwise } from 'clustal-js'
|
|
63
|
+
const file = fs.readFileSync('test.aln', 'utf8')
|
|
64
|
+
const ret = parse(file)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Input test.aln (e.g. from EMBOSS needle)
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
########################################
|
|
71
|
+
# Program: needle
|
|
72
|
+
# Rundate: Mon 5 Feb 2024 17:52:19
|
|
73
|
+
# Commandline: needle
|
|
74
|
+
# -auto
|
|
75
|
+
# -stdout
|
|
76
|
+
# -asequence emboss_needle-R20240205-175207-0261-70863964-p1m.asequence
|
|
77
|
+
# -bsequence emboss_needle-R20240205-175207-0261-70863964-p1m.bsequence
|
|
78
|
+
# Align_format: srspair
|
|
79
|
+
# Report_file: stdout
|
|
80
|
+
########################################
|
|
81
|
+
|
|
82
|
+
#=======================================
|
|
83
|
+
#
|
|
84
|
+
# Aligned_sequences: 2
|
|
85
|
+
# 1: a
|
|
86
|
+
# 2: b
|
|
87
|
+
# Matrix: EBLOSUM62
|
|
88
|
+
# Gap_penalty: 10.0
|
|
89
|
+
# Extend_penalty: 0.5
|
|
90
|
+
#
|
|
91
|
+
# Length: 614
|
|
92
|
+
# Identity: 221/614 (36.0%)
|
|
93
|
+
# Similarity: 221/614 (36.0%)
|
|
94
|
+
# Gaps: 393/614 (64.0%)
|
|
95
|
+
# Score: 1114.0
|
|
96
|
+
#
|
|
97
|
+
#
|
|
98
|
+
#=======================================
|
|
99
|
+
|
|
100
|
+
a 1 MGQKGHKDSLYPCGGTPESSLHEALDQCMTALDLFLTNQFSEALSYLKPR 50
|
|
101
|
+
|
|
102
|
+
b 0 -------------------------------------------------- 0
|
|
103
|
+
|
|
104
|
+
a 51 TKESMYHSLTYATILEMQAMMTFDPQDILLAGNMMKEAQMLCQRHRRKSS 100
|
|
105
|
+
|
|
106
|
+
b 0 -------------------------------------------------- 0
|
|
107
|
+
|
|
108
|
+
a 101 VTDSFSSLVNRPTLGQFTEEEIHAEVCYAECLLQRAALTFLQGSSHGGAV 150
|
|
109
|
+
|
|
110
|
+
b 0 -------------------------------------------------- 0
|
|
111
|
+
|
|
112
|
+
a 151 RPRALHDPSHACSCPPGPGRQHLFLLQDENMVSFIKGGIKVRNSYQTYKE 200
|
|
113
|
+
|
|
114
|
+
b 0 -------------------------------------------------- 0
|
|
115
|
+
|
|
116
|
+
a 201 LDSLVQSSQYCKGENHPHFEGGVKLGVGAFNLTLSMLPTRILRLLEFVGF 250
|
|
117
|
+
|
|
118
|
+
b 0 -------------------------------------------------- 0
|
|
119
|
+
|
|
120
|
+
a 251 SGNKDYGLLQLEEGASGHSFRSVLCVMLLLCYHTFLTFVLGTGNVNIEEA 300
|
|
121
|
+
|
|
122
|
+
b 0 -------------------------------------------------- 0
|
|
123
|
+
|
|
124
|
+
a 301 EKLLKPYLNRYPKGAIFLFFAGRIEVIKGNIDAAIRRFEECCEAQQHWKQ 350
|
|
125
|
+
|
|
126
|
+
b 0 -------------------------------------------------- 0
|
|
127
|
+
|
|
128
|
+
a 351 FHHMCYWELMWCFTYKGQWKMSYFYADLLSKENCWSKATYIYMKAAYLSM 400
|
|
129
|
+
||||||||
|
|
130
|
+
b 1 ------------------------------------------MKAAYLSM 8
|
|
131
|
+
|
|
132
|
+
a 401 FGKEDHKPFGDDEVELFRAVPGLKLKIAGKSLPTEKFAIRKSRRYFSSNP 450
|
|
133
|
+
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
134
|
+
b 9 FGKEDHKPFGDDEVELFRAVPGLKLKIAGKSLPTEKFAIRKSRRYFSSNP 58
|
|
135
|
+
|
|
136
|
+
a 451 ISLPVPALEMMYIWNGYAVIGKQPKLTDGILEIITKAEEMLEKGPENEYS 500
|
|
137
|
+
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
138
|
+
b 59 ISLPVPALEMMYIWNGYAVIGKQPKLTDGILEIITKAEEMLEKGPENEYS 108
|
|
139
|
+
|
|
140
|
+
a 501 VDDECLVKLLKGLCLKYLGRVQEAEENFRSISANEKKIKYDHYLIPNALL 550
|
|
141
|
+
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
142
|
+
b 109 VDDECLVKLLKGLCLKYLGRVQEAEENFRSISANEKKIKYDHYLIPNALL 158
|
|
143
|
+
|
|
144
|
+
a 551 ELALLLMEQDRNEEAIKLLESAKQNYKNYSMESRTHFRIQAATLQAKSSL 600
|
|
145
|
+
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
146
|
+
b 159 ELALLLMEQDRNEEAIKLLESAKQNYKNYSMESRTHFRIQAATLQAKSSL 208
|
|
147
|
+
|
|
148
|
+
a 601 ENSSRSMVSSVSL- 613
|
|
149
|
+
|||||||||||||
|
|
150
|
+
b 209 ENSSRSMVSSVSL* 222
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
#---------------------------------------
|
|
154
|
+
#---------------------------------------
|
|
155
|
+
```
|
|
60
156
|
|
|
61
157
|
### Notes
|
|
62
158
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clustal-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": "cmdcolin/clustal-js",
|
|
6
6
|
"files": [
|
|
@@ -8,28 +8,18 @@
|
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@
|
|
12
|
-
"@
|
|
13
|
-
"@
|
|
14
|
-
"@
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"eslint": "^7.19.0",
|
|
24
|
-
"eslint-config-airbnb-base": "^14.2.1",
|
|
25
|
-
"eslint-config-prettier": "^7.2.0",
|
|
26
|
-
"eslint-plugin-import": "^2.22.1",
|
|
27
|
-
"eslint-plugin-prettier": "^3.3.1",
|
|
28
|
-
"jest": "^26.6.3",
|
|
29
|
-
"jest-cli": "^26.6.3",
|
|
30
|
-
"prettier": "^2.2.1",
|
|
31
|
-
"ts-jest": "^26.5.0",
|
|
32
|
-
"typescript": "^4.1.3"
|
|
11
|
+
"@types/jest": "^29.5.12",
|
|
12
|
+
"@types/node": "^20.11.16",
|
|
13
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
14
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
15
|
+
"eslint": "^8.56.0",
|
|
16
|
+
"eslint-config-prettier": "^9.1.0",
|
|
17
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
18
|
+
"eslint-plugin-unicorn": "^50.0.1",
|
|
19
|
+
"jest": "^29.7.0",
|
|
20
|
+
"prettier": "^3.2.5",
|
|
21
|
+
"ts-jest": "^29.1.2",
|
|
22
|
+
"typescript": "^5.3.3"
|
|
33
23
|
},
|
|
34
24
|
"scripts": {
|
|
35
25
|
"test": "jest",
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse = exports.parseIter = void 0;
|
|
4
|
-
const util_1 = require("./util");
|
|
5
|
-
function parseIter(arr) {
|
|
6
|
-
const line = util_1.getFirstNonEmptyLine(arr);
|
|
7
|
-
if (!line)
|
|
8
|
-
throw new Error("Empty file received");
|
|
9
|
-
const header = util_1.parseHeader(line);
|
|
10
|
-
const res = util_1.parseBlocks(arr);
|
|
11
|
-
if (res === undefined)
|
|
12
|
-
throw new Error("No blocks parsed");
|
|
13
|
-
const alns = res.seqs.map((n, index) => ({ id: res.ids[index], seq: n }));
|
|
14
|
-
const { consensus } = res;
|
|
15
|
-
if (consensus.length != alns[0].seq.length) {
|
|
16
|
-
throw new Error(`Consensus length != sequence length. Con ${consensus.length} seq ${alns[0].seq.length}`);
|
|
17
|
-
}
|
|
18
|
-
return { consensus, alns, header };
|
|
19
|
-
}
|
|
20
|
-
exports.parseIter = parseIter;
|
|
21
|
-
function parse(contents) {
|
|
22
|
-
const iter = contents.split("\n")[Symbol.iterator]();
|
|
23
|
-
return parseIter(iter);
|
|
24
|
-
}
|
|
25
|
-
exports.parse = parse;
|
package/dist/types.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface Header {
|
|
2
|
-
version: string;
|
|
3
|
-
info: string;
|
|
4
|
-
}
|
|
5
|
-
export interface Alignment {
|
|
6
|
-
id: string;
|
|
7
|
-
seq: string;
|
|
8
|
-
}
|
|
9
|
-
export interface Block {
|
|
10
|
-
consensus: string;
|
|
11
|
-
seqs: string[];
|
|
12
|
-
ids: string[];
|
|
13
|
-
}
|
|
14
|
-
export interface Results {
|
|
15
|
-
header: Header;
|
|
16
|
-
alns: Alignment[];
|
|
17
|
-
consensus: string;
|
|
18
|
-
}
|
package/dist/types.js
DELETED
package/dist/util.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Header, Block } from "./types";
|
|
2
|
-
export declare function parseVersion(line: string): string;
|
|
3
|
-
export declare function parseHeader(info: string): Header;
|
|
4
|
-
export declare function getFirstNonEmptyLine(arr: Iterator<string>): string;
|
|
5
|
-
export declare function getSeqBounds(line: string): number[];
|
|
6
|
-
export declare function parseBlock(arr: Iterator<string>): Block | undefined;
|
|
7
|
-
export declare function parseBlocks(arr: Iterator<string>): Block | undefined;
|
package/dist/util.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseBlocks = exports.parseBlock = exports.getSeqBounds = exports.getFirstNonEmptyLine = exports.parseHeader = exports.parseVersion = void 0;
|
|
4
|
-
function parseVersion(line) {
|
|
5
|
-
const res = line.match(/\(?(\d+(\.\d+)+)\)?/);
|
|
6
|
-
return res && res.length > 1 ? res[1] : "";
|
|
7
|
-
}
|
|
8
|
-
exports.parseVersion = parseVersion;
|
|
9
|
-
function parseHeader(info) {
|
|
10
|
-
const knownHeaders = ["CLUSTAL", "PROBCONS", "MUSCLE", "MSAPROBS", "Kalign"];
|
|
11
|
-
if (!knownHeaders.find((l) => info.startsWith(l))) {
|
|
12
|
-
console.warn(`${info} is not a known CLUSTAL header: ${knownHeaders.join(",")}, proceeding but could indicate an issue`);
|
|
13
|
-
}
|
|
14
|
-
const version = parseVersion(info);
|
|
15
|
-
return { info, version };
|
|
16
|
-
}
|
|
17
|
-
exports.parseHeader = parseHeader;
|
|
18
|
-
function getFirstNonEmptyLine(arr) {
|
|
19
|
-
// There should be two blank lines after the header line
|
|
20
|
-
let line = arr.next();
|
|
21
|
-
while (!line.done && line.value.trim() === "") {
|
|
22
|
-
line = arr.next();
|
|
23
|
-
}
|
|
24
|
-
return line.value;
|
|
25
|
-
}
|
|
26
|
-
exports.getFirstNonEmptyLine = getFirstNonEmptyLine;
|
|
27
|
-
function getSeqBounds(line) {
|
|
28
|
-
const fields = line.split(/\s+/);
|
|
29
|
-
const temp = line.slice(fields[0].length);
|
|
30
|
-
const s = fields[0].length + temp.indexOf(fields[1]);
|
|
31
|
-
const e = s + fields[1].length;
|
|
32
|
-
return [s, e];
|
|
33
|
-
}
|
|
34
|
-
exports.getSeqBounds = getSeqBounds;
|
|
35
|
-
// Use the first block to get the sequence identifiers
|
|
36
|
-
function parseBlock(arr) {
|
|
37
|
-
let line = getFirstNonEmptyLine(arr);
|
|
38
|
-
const block = [];
|
|
39
|
-
let consensusLine = "";
|
|
40
|
-
if (!line)
|
|
41
|
-
return undefined;
|
|
42
|
-
while (line) {
|
|
43
|
-
if (line[0] !== " ")
|
|
44
|
-
block.push(line);
|
|
45
|
-
else
|
|
46
|
-
consensusLine = line;
|
|
47
|
-
line = arr.next().value;
|
|
48
|
-
}
|
|
49
|
-
const [start, end] = getSeqBounds(block[0]);
|
|
50
|
-
const fields = block.map((s) => s.split(/\s+/));
|
|
51
|
-
const ids = fields.map((s) => s[0]);
|
|
52
|
-
const seqs = block.map((s) => s.slice(start, end));
|
|
53
|
-
let consensus = consensusLine.slice(start, end);
|
|
54
|
-
// handle if the consensus trailing whitespace got trimmed
|
|
55
|
-
const remainder = seqs[0].length - consensus.length;
|
|
56
|
-
if (remainder) {
|
|
57
|
-
consensus += " ".repeat(remainder);
|
|
58
|
-
}
|
|
59
|
-
return { ids, seqs, consensus };
|
|
60
|
-
}
|
|
61
|
-
exports.parseBlock = parseBlock;
|
|
62
|
-
function parseBlocks(arr) {
|
|
63
|
-
let block;
|
|
64
|
-
const res = parseBlock(arr);
|
|
65
|
-
if (res !== undefined) {
|
|
66
|
-
while ((block = parseBlock(arr))) {
|
|
67
|
-
for (let i = 0; i < block.seqs.length; i++) {
|
|
68
|
-
res.seqs[i] += block.seqs[i];
|
|
69
|
-
}
|
|
70
|
-
res.consensus += block.consensus;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return res;
|
|
74
|
-
}
|
|
75
|
-
exports.parseBlocks = parseBlocks;
|