@rtemis/a3 0.1.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/LICENSE.txt +373 -0
- package/dist/a3.d.ts +43 -0
- package/dist/a3.d.ts.map +1 -0
- package/dist/a3.js +93 -0
- package/dist/a3.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +14 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +32 -0
- package/dist/io.js.map +1 -0
- package/dist/normalize.d.ts +17 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +35 -0
- package/dist/normalize.js.map +1 -0
- package/dist/schemas.d.ts +294 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +131 -0
- package/dist/schemas.js.map +1 -0
- package/package.json +39 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
Mozilla Public License Version 2.0
|
|
2
|
+
==================================
|
|
3
|
+
|
|
4
|
+
1. Definitions
|
|
5
|
+
--------------
|
|
6
|
+
|
|
7
|
+
1.1. "Contributor"
|
|
8
|
+
means each individual or legal entity that creates, contributes to
|
|
9
|
+
the creation of, or owns Covered Software.
|
|
10
|
+
|
|
11
|
+
1.2. "Contributor Version"
|
|
12
|
+
means the combination of the Contributions of others (if any) used
|
|
13
|
+
by a Contributor and that particular Contributor's Contribution.
|
|
14
|
+
|
|
15
|
+
1.3. "Contribution"
|
|
16
|
+
means Covered Software of a particular Contributor.
|
|
17
|
+
|
|
18
|
+
1.4. "Covered Software"
|
|
19
|
+
means Source Code Form to which the initial Contributor has attached
|
|
20
|
+
the notice in Exhibit A, the Executable Form of such Source Code
|
|
21
|
+
Form, and Modifications of such Source Code Form, in each case
|
|
22
|
+
including portions thereof.
|
|
23
|
+
|
|
24
|
+
1.5. "Incompatible With Secondary Licenses"
|
|
25
|
+
means
|
|
26
|
+
|
|
27
|
+
(a) that the initial Contributor has attached the notice described
|
|
28
|
+
in Exhibit B to the Covered Software; or
|
|
29
|
+
|
|
30
|
+
(b) that the Covered Software was made available under the terms of
|
|
31
|
+
version 1.1 or earlier of the License, but not also under the
|
|
32
|
+
terms of a Secondary License.
|
|
33
|
+
|
|
34
|
+
1.6. "Executable Form"
|
|
35
|
+
means any form of the work other than Source Code Form.
|
|
36
|
+
|
|
37
|
+
1.7. "Larger Work"
|
|
38
|
+
means a work that combines Covered Software with other material, in
|
|
39
|
+
a separate file or files, that is not Covered Software.
|
|
40
|
+
|
|
41
|
+
1.8. "License"
|
|
42
|
+
means this document.
|
|
43
|
+
|
|
44
|
+
1.9. "Licensable"
|
|
45
|
+
means having the right to grant, to the maximum extent possible,
|
|
46
|
+
whether at the time of the initial grant or subsequently, any and
|
|
47
|
+
all of the rights conveyed by this License.
|
|
48
|
+
|
|
49
|
+
1.10. "Modifications"
|
|
50
|
+
means any of the following:
|
|
51
|
+
|
|
52
|
+
(a) any file in Source Code Form that results from an addition to,
|
|
53
|
+
deletion from, or modification of the contents of Covered
|
|
54
|
+
Software; or
|
|
55
|
+
|
|
56
|
+
(b) any new file in Source Code Form that contains any Covered
|
|
57
|
+
Software.
|
|
58
|
+
|
|
59
|
+
1.11. "Patent Claims" of a Contributor
|
|
60
|
+
means any patent claim(s), including without limitation, method,
|
|
61
|
+
process, and apparatus claims, in any patent Licensable by such
|
|
62
|
+
Contributor that would be infringed, but for the grant of the
|
|
63
|
+
License, by the making, using, selling, offering for sale, having
|
|
64
|
+
made, import, or transfer of either its Contributions or its
|
|
65
|
+
Contributor Version.
|
|
66
|
+
|
|
67
|
+
1.12. "Secondary License"
|
|
68
|
+
means either the GNU General Public License, Version 2.0, the GNU
|
|
69
|
+
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
70
|
+
Public License, Version 3.0, or any later versions of those
|
|
71
|
+
licenses.
|
|
72
|
+
|
|
73
|
+
1.13. "Source Code Form"
|
|
74
|
+
means the form of the work preferred for making modifications.
|
|
75
|
+
|
|
76
|
+
1.14. "You" (or "Your")
|
|
77
|
+
means an individual or a legal entity exercising rights under this
|
|
78
|
+
License. For legal entities, "You" includes any entity that
|
|
79
|
+
controls, is controlled by, or is under common control with You. For
|
|
80
|
+
purposes of this definition, "control" means (a) the power, direct
|
|
81
|
+
or indirect, to cause the direction or management of such entity,
|
|
82
|
+
whether by contract or otherwise, or (b) ownership of more than
|
|
83
|
+
fifty percent (50%) of the outstanding shares or beneficial
|
|
84
|
+
ownership of such entity.
|
|
85
|
+
|
|
86
|
+
2. License Grants and Conditions
|
|
87
|
+
--------------------------------
|
|
88
|
+
|
|
89
|
+
2.1. Grants
|
|
90
|
+
|
|
91
|
+
Each Contributor hereby grants You a world-wide, royalty-free,
|
|
92
|
+
non-exclusive license:
|
|
93
|
+
|
|
94
|
+
(a) under intellectual property rights (other than patent or trademark)
|
|
95
|
+
Licensable by such Contributor to use, reproduce, make available,
|
|
96
|
+
modify, display, perform, distribute, and otherwise exploit its
|
|
97
|
+
Contributions, either on an unmodified basis, with Modifications, or
|
|
98
|
+
as part of a Larger Work; and
|
|
99
|
+
|
|
100
|
+
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
|
101
|
+
for sale, have made, import, and otherwise transfer either its
|
|
102
|
+
Contributions or its Contributor Version.
|
|
103
|
+
|
|
104
|
+
2.2. Effective Date
|
|
105
|
+
|
|
106
|
+
The licenses granted in Section 2.1 with respect to any Contribution
|
|
107
|
+
become effective for each Contribution on the date the Contributor first
|
|
108
|
+
distributes such Contribution.
|
|
109
|
+
|
|
110
|
+
2.3. Limitations on Grant Scope
|
|
111
|
+
|
|
112
|
+
The licenses granted in this Section 2 are the only rights granted under
|
|
113
|
+
this License. No additional rights or licenses will be implied from the
|
|
114
|
+
distribution or licensing of Covered Software under this License.
|
|
115
|
+
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
116
|
+
Contributor:
|
|
117
|
+
|
|
118
|
+
(a) for any code that a Contributor has removed from Covered Software;
|
|
119
|
+
or
|
|
120
|
+
|
|
121
|
+
(b) for infringements caused by: (i) Your and any other third party's
|
|
122
|
+
modifications of Covered Software, or (ii) the combination of its
|
|
123
|
+
Contributions with other software (except as part of its Contributor
|
|
124
|
+
Version); or
|
|
125
|
+
|
|
126
|
+
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
127
|
+
its Contributions.
|
|
128
|
+
|
|
129
|
+
This License does not grant any rights in the trademarks, service marks,
|
|
130
|
+
or logos of any Contributor (except as may be necessary to comply with
|
|
131
|
+
the notice requirements in Section 3.4).
|
|
132
|
+
|
|
133
|
+
2.4. Subsequent Licenses
|
|
134
|
+
|
|
135
|
+
No Contributor makes additional grants as a result of Your choice to
|
|
136
|
+
distribute the Covered Software under a subsequent version of this
|
|
137
|
+
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
138
|
+
permitted under the terms of Section 3.3).
|
|
139
|
+
|
|
140
|
+
2.5. Representation
|
|
141
|
+
|
|
142
|
+
Each Contributor represents that the Contributor believes its
|
|
143
|
+
Contributions are its original creation(s) or it has sufficient rights
|
|
144
|
+
to grant the rights to its Contributions conveyed by this License.
|
|
145
|
+
|
|
146
|
+
2.6. Fair Use
|
|
147
|
+
|
|
148
|
+
This License is not intended to limit any rights You have under
|
|
149
|
+
applicable copyright doctrines of fair use, fair dealing, or other
|
|
150
|
+
equivalents.
|
|
151
|
+
|
|
152
|
+
2.7. Conditions
|
|
153
|
+
|
|
154
|
+
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
155
|
+
in Section 2.1.
|
|
156
|
+
|
|
157
|
+
3. Responsibilities
|
|
158
|
+
-------------------
|
|
159
|
+
|
|
160
|
+
3.1. Distribution of Source Form
|
|
161
|
+
|
|
162
|
+
All distribution of Covered Software in Source Code Form, including any
|
|
163
|
+
Modifications that You create or to which You contribute, must be under
|
|
164
|
+
the terms of this License. You must inform recipients that the Source
|
|
165
|
+
Code Form of the Covered Software is governed by the terms of this
|
|
166
|
+
License, and how they can obtain a copy of this License. You may not
|
|
167
|
+
attempt to alter or restrict the recipients' rights in the Source Code
|
|
168
|
+
Form.
|
|
169
|
+
|
|
170
|
+
3.2. Distribution of Executable Form
|
|
171
|
+
|
|
172
|
+
If You distribute Covered Software in Executable Form then:
|
|
173
|
+
|
|
174
|
+
(a) such Covered Software must also be made available in Source Code
|
|
175
|
+
Form, as described in Section 3.1, and You must inform recipients of
|
|
176
|
+
the Executable Form how they can obtain a copy of such Source Code
|
|
177
|
+
Form by reasonable means in a timely manner, at a charge no more
|
|
178
|
+
than the cost of distribution to the recipient; and
|
|
179
|
+
|
|
180
|
+
(b) You may distribute such Executable Form under the terms of this
|
|
181
|
+
License, or sublicense it under different terms, provided that the
|
|
182
|
+
license for the Executable Form does not attempt to limit or alter
|
|
183
|
+
the recipients' rights in the Source Code Form under this License.
|
|
184
|
+
|
|
185
|
+
3.3. Distribution of a Larger Work
|
|
186
|
+
|
|
187
|
+
You may create and distribute a Larger Work under terms of Your choice,
|
|
188
|
+
provided that You also comply with the requirements of this License for
|
|
189
|
+
the Covered Software. If the Larger Work is a combination of Covered
|
|
190
|
+
Software with a work governed by one or more Secondary Licenses, and the
|
|
191
|
+
Covered Software is not Incompatible With Secondary Licenses, this
|
|
192
|
+
License permits You to additionally distribute such Covered Software
|
|
193
|
+
under the terms of such Secondary License(s), so that the recipient of
|
|
194
|
+
the Larger Work may, at their option, further distribute the Covered
|
|
195
|
+
Software under the terms of either this License or such Secondary
|
|
196
|
+
License(s).
|
|
197
|
+
|
|
198
|
+
3.4. Notices
|
|
199
|
+
|
|
200
|
+
You may not remove or alter the substance of any license notices
|
|
201
|
+
(including copyright notices, patent notices, disclaimers of warranty,
|
|
202
|
+
or limitations of liability) contained within the Source Code Form of
|
|
203
|
+
the Covered Software, except that You may alter any license notices to
|
|
204
|
+
the extent required to remedy known factual inaccuracies.
|
|
205
|
+
|
|
206
|
+
3.5. Application of Additional Terms
|
|
207
|
+
|
|
208
|
+
You may choose to offer, and to charge a fee for, warranty, support,
|
|
209
|
+
indemnity or liability obligations to one or more recipients of Covered
|
|
210
|
+
Software. However, You may do so only on Your own behalf, and not on
|
|
211
|
+
behalf of any Contributor. You must make it absolutely clear that any
|
|
212
|
+
such warranty, support, indemnity, or liability obligation is offered by
|
|
213
|
+
You alone, and You hereby agree to indemnify every Contributor for any
|
|
214
|
+
liability incurred by such Contributor as a result of warranty, support,
|
|
215
|
+
indemnity or liability terms You offer. You may include additional
|
|
216
|
+
disclaimers of warranty and limitations of liability specific to any
|
|
217
|
+
jurisdiction.
|
|
218
|
+
|
|
219
|
+
4. Inability to Comply Due to Statute or Regulation
|
|
220
|
+
---------------------------------------------------
|
|
221
|
+
|
|
222
|
+
If it is impossible for You to comply with any of the terms of this
|
|
223
|
+
License with respect to some or all of the Covered Software due to
|
|
224
|
+
statute, judicial order, or regulation then You must: (a) comply with
|
|
225
|
+
the terms of this License to the maximum extent possible; and (b)
|
|
226
|
+
describe the limitations and the code they affect. Such description must
|
|
227
|
+
be placed in a text file included with all distributions of the Covered
|
|
228
|
+
Software under this License. Except to the extent prohibited by statute
|
|
229
|
+
or regulation, such description must be sufficiently detailed for a
|
|
230
|
+
recipient of ordinary skill to be able to understand it.
|
|
231
|
+
|
|
232
|
+
5. Termination
|
|
233
|
+
--------------
|
|
234
|
+
|
|
235
|
+
5.1. The rights granted under this License will terminate automatically
|
|
236
|
+
if You fail to comply with any of its terms. However, if You become
|
|
237
|
+
compliant, then the rights granted under this License from a particular
|
|
238
|
+
Contributor are reinstated (a) provisionally, unless and until such
|
|
239
|
+
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
240
|
+
ongoing basis, if such Contributor fails to notify You of the
|
|
241
|
+
non-compliance by some reasonable means prior to 60 days after You have
|
|
242
|
+
come back into compliance. Moreover, Your grants from a particular
|
|
243
|
+
Contributor are reinstated on an ongoing basis if such Contributor
|
|
244
|
+
notifies You of the non-compliance by some reasonable means, this is the
|
|
245
|
+
first time You have received notice of non-compliance with this License
|
|
246
|
+
from such Contributor, and You become compliant prior to 30 days after
|
|
247
|
+
Your receipt of the notice.
|
|
248
|
+
|
|
249
|
+
5.2. If You initiate litigation against any entity by asserting a patent
|
|
250
|
+
infringement claim (excluding declaratory judgment actions,
|
|
251
|
+
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
252
|
+
directly or indirectly infringes any patent, then the rights granted to
|
|
253
|
+
You by any and all Contributors for the Covered Software under Section
|
|
254
|
+
2.1 of this License shall terminate.
|
|
255
|
+
|
|
256
|
+
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
257
|
+
end user license agreements (excluding distributors and resellers) which
|
|
258
|
+
have been validly granted by You or Your distributors under this License
|
|
259
|
+
prior to termination shall survive termination.
|
|
260
|
+
|
|
261
|
+
************************************************************************
|
|
262
|
+
* *
|
|
263
|
+
* 6. Disclaimer of Warranty *
|
|
264
|
+
* ------------------------- *
|
|
265
|
+
* *
|
|
266
|
+
* Covered Software is provided under this License on an "as is" *
|
|
267
|
+
* basis, without warranty of any kind, either expressed, implied, or *
|
|
268
|
+
* statutory, including, without limitation, warranties that the *
|
|
269
|
+
* Covered Software is free of defects, merchantable, fit for a *
|
|
270
|
+
* particular purpose or non-infringing. The entire risk as to the *
|
|
271
|
+
* quality and performance of the Covered Software is with You. *
|
|
272
|
+
* Should any Covered Software prove defective in any respect, You *
|
|
273
|
+
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
274
|
+
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
275
|
+
* essential part of this License. No use of any Covered Software is *
|
|
276
|
+
* authorized under this License except under this disclaimer. *
|
|
277
|
+
* *
|
|
278
|
+
************************************************************************
|
|
279
|
+
|
|
280
|
+
************************************************************************
|
|
281
|
+
* *
|
|
282
|
+
* 7. Limitation of Liability *
|
|
283
|
+
* -------------------------- *
|
|
284
|
+
* *
|
|
285
|
+
* Under no circumstances and under no legal theory, whether tort *
|
|
286
|
+
* (including negligence), contract, or otherwise, shall any *
|
|
287
|
+
* Contributor, or anyone who distributes Covered Software as *
|
|
288
|
+
* permitted above, be liable to You for any direct, indirect, *
|
|
289
|
+
* special, incidental, or consequential damages of any character *
|
|
290
|
+
* including, without limitation, damages for lost profits, loss of *
|
|
291
|
+
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
292
|
+
* and all other commercial damages or losses, even if such party *
|
|
293
|
+
* shall have been informed of the possibility of such damages. This *
|
|
294
|
+
* limitation of liability shall not apply to liability for death or *
|
|
295
|
+
* personal injury resulting from such party's negligence to the *
|
|
296
|
+
* extent applicable law prohibits such limitation. Some *
|
|
297
|
+
* jurisdictions do not allow the exclusion or limitation of *
|
|
298
|
+
* incidental or consequential damages, so this exclusion and *
|
|
299
|
+
* limitation may not apply to You. *
|
|
300
|
+
* *
|
|
301
|
+
************************************************************************
|
|
302
|
+
|
|
303
|
+
8. Litigation
|
|
304
|
+
-------------
|
|
305
|
+
|
|
306
|
+
Any litigation relating to this License may be brought only in the
|
|
307
|
+
courts of a jurisdiction where the defendant maintains its principal
|
|
308
|
+
place of business and such litigation shall be governed by laws of that
|
|
309
|
+
jurisdiction, without reference to its conflict-of-law provisions.
|
|
310
|
+
Nothing in this Section shall prevent a party's ability to bring
|
|
311
|
+
cross-claims or counter-claims.
|
|
312
|
+
|
|
313
|
+
9. Miscellaneous
|
|
314
|
+
----------------
|
|
315
|
+
|
|
316
|
+
This License represents the complete agreement concerning the subject
|
|
317
|
+
matter hereof. If any provision of this License is held to be
|
|
318
|
+
unenforceable, such provision shall be reformed only to the extent
|
|
319
|
+
necessary to make it enforceable. Any law or regulation which provides
|
|
320
|
+
that the language of a contract shall be construed against the drafter
|
|
321
|
+
shall not be used to construe this License against a Contributor.
|
|
322
|
+
|
|
323
|
+
10. Versions of the License
|
|
324
|
+
---------------------------
|
|
325
|
+
|
|
326
|
+
10.1. New Versions
|
|
327
|
+
|
|
328
|
+
Mozilla Foundation is the license steward. Except as provided in Section
|
|
329
|
+
10.3, no one other than the license steward has the right to modify or
|
|
330
|
+
publish new versions of this License. Each version will be given a
|
|
331
|
+
distinguishing version number.
|
|
332
|
+
|
|
333
|
+
10.2. Effect of New Versions
|
|
334
|
+
|
|
335
|
+
You may distribute the Covered Software under the terms of the version
|
|
336
|
+
of the License under which You originally received the Covered Software,
|
|
337
|
+
or under the terms of any subsequent version published by the license
|
|
338
|
+
steward.
|
|
339
|
+
|
|
340
|
+
10.3. Modified Versions
|
|
341
|
+
|
|
342
|
+
If you create software not governed by this License, and you want to
|
|
343
|
+
create a new license for such software, you may create and use a
|
|
344
|
+
modified version of this License if you rename the license and remove
|
|
345
|
+
any references to the name of the license steward (except to note that
|
|
346
|
+
such modified license differs from this License).
|
|
347
|
+
|
|
348
|
+
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
349
|
+
Licenses
|
|
350
|
+
|
|
351
|
+
If You choose to distribute Source Code Form that is Incompatible With
|
|
352
|
+
Secondary Licenses under the terms of this version of the License, the
|
|
353
|
+
notice described in Exhibit B of this License must be attached.
|
|
354
|
+
|
|
355
|
+
Exhibit A - Source Code Form License Notice
|
|
356
|
+
-------------------------------------------
|
|
357
|
+
|
|
358
|
+
This Source Code Form is subject to the terms of the Mozilla Public
|
|
359
|
+
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
360
|
+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
361
|
+
|
|
362
|
+
If it is not possible or desirable to put the notice in a particular
|
|
363
|
+
file, then You may include the notice in a location (such as a LICENSE
|
|
364
|
+
file in a relevant directory) where a recipient would be likely to look
|
|
365
|
+
for such a notice.
|
|
366
|
+
|
|
367
|
+
You may add additional accurate notices of copyright ownership.
|
|
368
|
+
|
|
369
|
+
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
370
|
+
---------------------------------------------------------
|
|
371
|
+
|
|
372
|
+
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
373
|
+
defined by the Mozilla Public License, v. 2.0.
|
package/dist/a3.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ZodError } from "zod";
|
|
2
|
+
import { type A3Data, type VariantData } from "./schemas";
|
|
3
|
+
export declare class A3ValidationError extends Error {
|
|
4
|
+
readonly issues: ZodError["issues"];
|
|
5
|
+
constructor(zodError: ZodError);
|
|
6
|
+
}
|
|
7
|
+
export declare class A3ParseError extends Error {
|
|
8
|
+
constructor(message: string, options?: ErrorOptions);
|
|
9
|
+
}
|
|
10
|
+
export declare class A3 {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(input: unknown);
|
|
13
|
+
static fromData(data: unknown): A3;
|
|
14
|
+
static fromJSONText(text: string): A3;
|
|
15
|
+
/** Number of residues in the sequence. */
|
|
16
|
+
get length(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Return the residue at a 1-based position.
|
|
19
|
+
* Throws RangeError if position is out of bounds.
|
|
20
|
+
*/
|
|
21
|
+
residueAt(position: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* Return all variants at a given 1-based position.
|
|
24
|
+
*/
|
|
25
|
+
variantsAt(position: number): VariantData[];
|
|
26
|
+
/**
|
|
27
|
+
* Return the canonical validated data object.
|
|
28
|
+
* The returned reference is frozen — spread to get a mutable copy.
|
|
29
|
+
*/
|
|
30
|
+
toData(): A3Data;
|
|
31
|
+
/**
|
|
32
|
+
* Return the canonical data object for JSON serialization.
|
|
33
|
+
* Called automatically by JSON.stringify — do not return a string here.
|
|
34
|
+
*/
|
|
35
|
+
toJSON(): A3Data;
|
|
36
|
+
/**
|
|
37
|
+
* Serialize to a JSON string.
|
|
38
|
+
* @param indent Number of spaces for indentation (default 2). Pass 0 for compact output.
|
|
39
|
+
*/
|
|
40
|
+
toJSONString(indent?: number): string;
|
|
41
|
+
toString(): string;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=a3.d.ts.map
|
package/dist/a3.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a3.d.ts","sourceRoot":"","sources":["../src/a3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,KAAK,MAAM,EAAiB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAIzE,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAExB,QAAQ,EAAE,QAAQ;CAK/B;AAED,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAID,qBAAa,EAAE;;gBAGD,KAAK,EAAE,OAAO;IAQ1B,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,EAAE;IAIlC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,EAAE;IAcrC,0CAA0C;IAC1C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IASnC;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE;IAM3C;;;OAGG;IACH,MAAM,IAAI,MAAM;IAIhB;;;OAGG;IACH,MAAM,IAAI,MAAM;IAIhB;;;OAGG;IACH,YAAY,CAAC,MAAM,SAAI,GAAG,MAAM;IAMhC,QAAQ,IAAI,MAAM;CAOnB"}
|
package/dist/a3.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { A3InputSchema } from "./schemas";
|
|
2
|
+
// ── Error classes ─────────────────────────────────────────────────────────────
|
|
3
|
+
export class A3ValidationError extends Error {
|
|
4
|
+
issues;
|
|
5
|
+
constructor(zodError) {
|
|
6
|
+
super(zodError.message);
|
|
7
|
+
this.name = "A3ValidationError";
|
|
8
|
+
this.issues = zodError.issues;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class A3ParseError extends Error {
|
|
12
|
+
constructor(message, options) {
|
|
13
|
+
super(message, options);
|
|
14
|
+
this.name = "A3ParseError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// ── A3 class ──────────────────────────────────────────────────────────────────
|
|
18
|
+
export class A3 {
|
|
19
|
+
#data;
|
|
20
|
+
constructor(input) {
|
|
21
|
+
const result = A3InputSchema.safeParse(input);
|
|
22
|
+
if (!result.success)
|
|
23
|
+
throw new A3ValidationError(result.error);
|
|
24
|
+
this.#data = Object.freeze(result.data);
|
|
25
|
+
}
|
|
26
|
+
// ── Static constructors ───────────────────────────────────────────────────
|
|
27
|
+
static fromData(data) {
|
|
28
|
+
return new A3(data);
|
|
29
|
+
}
|
|
30
|
+
static fromJSONText(text) {
|
|
31
|
+
let parsed;
|
|
32
|
+
try {
|
|
33
|
+
parsed = JSON.parse(text);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
throw new A3ParseError("Invalid JSON", { cause: e });
|
|
37
|
+
}
|
|
38
|
+
return new A3(parsed);
|
|
39
|
+
}
|
|
40
|
+
// readJSON is provided in io.ts and re-exported from index.ts
|
|
41
|
+
// ── Accessors ─────────────────────────────────────────────────────────────
|
|
42
|
+
/** Number of residues in the sequence. */
|
|
43
|
+
get length() {
|
|
44
|
+
return this.#data.sequence.length;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Return the residue at a 1-based position.
|
|
48
|
+
* Throws RangeError if position is out of bounds.
|
|
49
|
+
*/
|
|
50
|
+
residueAt(position) {
|
|
51
|
+
if (!Number.isInteger(position) || position < 1 || position > this.length) {
|
|
52
|
+
throw new RangeError(`position ${position} is out of bounds for sequence of length ${this.length} (must be 1–${this.length})`);
|
|
53
|
+
}
|
|
54
|
+
return this.#data.sequence.charAt(position - 1);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Return all variants at a given 1-based position.
|
|
58
|
+
*/
|
|
59
|
+
variantsAt(position) {
|
|
60
|
+
return this.#data.annotations.variant.filter((v) => v.position === position);
|
|
61
|
+
}
|
|
62
|
+
// ── Serialization ─────────────────────────────────────────────────────────
|
|
63
|
+
/**
|
|
64
|
+
* Return the canonical validated data object.
|
|
65
|
+
* The returned reference is frozen — spread to get a mutable copy.
|
|
66
|
+
*/
|
|
67
|
+
toData() {
|
|
68
|
+
return this.#data;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Return the canonical data object for JSON serialization.
|
|
72
|
+
* Called automatically by JSON.stringify — do not return a string here.
|
|
73
|
+
*/
|
|
74
|
+
toJSON() {
|
|
75
|
+
return this.#data;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Serialize to a JSON string.
|
|
79
|
+
* @param indent Number of spaces for indentation (default 2). Pass 0 for compact output.
|
|
80
|
+
*/
|
|
81
|
+
toJSONString(indent = 2) {
|
|
82
|
+
return JSON.stringify(this, null, indent);
|
|
83
|
+
}
|
|
84
|
+
// ── Introspection ─────────────────────────────────────────────────────────
|
|
85
|
+
toString() {
|
|
86
|
+
const seq = this.#data.sequence;
|
|
87
|
+
const preview = seq.length > 12 ? `${seq.slice(0, 12)}…` : seq;
|
|
88
|
+
const id = this.#data.metadata.uniprot_id;
|
|
89
|
+
const label = id ? ` [${id}]` : "";
|
|
90
|
+
return `A3${label} { length: ${this.length}, sequence: "${preview}" }`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=a3.js.map
|
package/dist/a3.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a3.js","sourceRoot":"","sources":["../src/a3.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,aAAa,EAAoB,MAAM,WAAW,CAAC;AAEzE,iFAAiF;AAEjF,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,MAAM,CAAqB;IAEpC,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACxB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,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,KAAK,cAAc,IAAI,CAAC,MAAM,gBAAgB,OAAO,KAAK,CAAC;IACzE,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC3C,YAAY,EACV,MAAM,EACN,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,EACf,aAAa,GACd,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC"}
|
package/dist/io.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A3 } from "./a3";
|
|
2
|
+
/**
|
|
3
|
+
* Read an A3 JSON file from disk and return a validated A3 instance.
|
|
4
|
+
* @param path Absolute or relative path to a .json file.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readJSON(path: string): Promise<A3>;
|
|
7
|
+
/**
|
|
8
|
+
* Write an A3 instance to a JSON file.
|
|
9
|
+
* @param a3 The A3 instance to serialize.
|
|
10
|
+
* @param path Absolute or relative path to write.
|
|
11
|
+
* @param indent Number of spaces for indentation (default 2).
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeJSON(a3: A3, path: string, indent?: number): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=io.d.ts.map
|
package/dist/io.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAgB,MAAM,MAAM,CAAC;AAExC;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAQxD;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAO/E"}
|
package/dist/io.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { A3, A3ParseError } from "./a3";
|
|
3
|
+
/**
|
|
4
|
+
* Read an A3 JSON file from disk and return a validated A3 instance.
|
|
5
|
+
* @param path Absolute or relative path to a .json file.
|
|
6
|
+
*/
|
|
7
|
+
export async function readJSON(path) {
|
|
8
|
+
let text;
|
|
9
|
+
try {
|
|
10
|
+
text = await readFile(path, "utf-8");
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
throw new A3ParseError(`Cannot read file: ${path}`, { cause: e });
|
|
14
|
+
}
|
|
15
|
+
return A3.fromJSONText(text);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Write an A3 instance to a JSON file.
|
|
19
|
+
* @param a3 The A3 instance to serialize.
|
|
20
|
+
* @param path Absolute or relative path to write.
|
|
21
|
+
* @param indent Number of spaces for indentation (default 2).
|
|
22
|
+
*/
|
|
23
|
+
export async function writeJSON(a3, path, indent = 2) {
|
|
24
|
+
const text = a3.toJSONString(indent);
|
|
25
|
+
try {
|
|
26
|
+
await writeFile(path, text, "utf-8");
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
throw new A3ParseError(`Cannot write file: ${path}`, { cause: e });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=io.js.map
|
package/dist/io.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,YAAY,CAAC,qBAAqB,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAAM,EAAE,IAAY,EAAE,MAAM,GAAG,CAAC;IAC9D,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,YAAY,CAAC,sBAAsB,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sort and deduplicate a position array.
|
|
3
|
+
* Input positions are assumed valid (positive integers) — validated by Zod before calling.
|
|
4
|
+
*/
|
|
5
|
+
export declare function sortDedup(arr: readonly number[]): number[];
|
|
6
|
+
/**
|
|
7
|
+
* Sort ranges by start position (then end position for ties).
|
|
8
|
+
* Input ranges are assumed valid (start < end) — validated by Zod before calling.
|
|
9
|
+
* Overlap detection is handled separately in the schema layer.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sortRanges(arr: readonly [number, number][]): [number, number][];
|
|
12
|
+
/**
|
|
13
|
+
* Recursively check that a value is JSON-compatible.
|
|
14
|
+
* Rejects undefined, functions, symbols, and class instances.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isJsonCompatible(v: unknown): boolean;
|
|
17
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAE/E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAUpD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sort and deduplicate a position array.
|
|
3
|
+
* Input positions are assumed valid (positive integers) — validated by Zod before calling.
|
|
4
|
+
*/
|
|
5
|
+
export function sortDedup(arr) {
|
|
6
|
+
return [...new Set(arr)].sort((a, b) => a - b);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Sort ranges by start position (then end position for ties).
|
|
10
|
+
* Input ranges are assumed valid (start < end) — validated by Zod before calling.
|
|
11
|
+
* Overlap detection is handled separately in the schema layer.
|
|
12
|
+
*/
|
|
13
|
+
export function sortRanges(arr) {
|
|
14
|
+
return [...arr].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Recursively check that a value is JSON-compatible.
|
|
18
|
+
* Rejects undefined, functions, symbols, and class instances.
|
|
19
|
+
*/
|
|
20
|
+
export function isJsonCompatible(v) {
|
|
21
|
+
if (v === null)
|
|
22
|
+
return true;
|
|
23
|
+
if (typeof v === "boolean" || typeof v === "number" || typeof v === "string")
|
|
24
|
+
return true;
|
|
25
|
+
if (Array.isArray(v))
|
|
26
|
+
return v.every(isJsonCompatible);
|
|
27
|
+
if (typeof v === "object") {
|
|
28
|
+
const proto = Object.getPrototypeOf(v);
|
|
29
|
+
if (proto !== Object.prototype && proto !== null)
|
|
30
|
+
return false;
|
|
31
|
+
return Object.values(v).every(isJsonCompatible);
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,GAAsB;IAC9C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAgC;IACzD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1F,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAY,CAAC;QAClD,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAC/D,OAAO,MAAM,CAAC,MAAM,CAAC,CAA4B,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const SiteEntrySchema: z.ZodObject<{
|
|
3
|
+
index: z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>;
|
|
4
|
+
type: z.ZodDefault<z.ZodString>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
index: number[];
|
|
7
|
+
type: string;
|
|
8
|
+
}, {
|
|
9
|
+
index: number[];
|
|
10
|
+
type?: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
declare const RegionEntrySchema: z.ZodObject<{
|
|
13
|
+
index: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, [number, number], [number, number]>, "many">, [number, number][], [number, number][]>, [number, number][], [number, number][]>;
|
|
14
|
+
type: z.ZodDefault<z.ZodString>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
index: [number, number][];
|
|
17
|
+
type: string;
|
|
18
|
+
}, {
|
|
19
|
+
index: [number, number][];
|
|
20
|
+
type?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
declare const FlexEntrySchema: z.ZodObject<{
|
|
23
|
+
index: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, [number, number], [number, number]>, "many">, [number, number][], [number, number][]>, [number, number][], [number, number][]>, z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>]>;
|
|
24
|
+
type: z.ZodDefault<z.ZodString>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
index: number[] | [number, number][];
|
|
27
|
+
type: string;
|
|
28
|
+
}, {
|
|
29
|
+
index: number[] | [number, number][];
|
|
30
|
+
type?: string | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
declare const VariantSchema: z.ZodEffects<z.ZodObject<{
|
|
33
|
+
position: z.ZodNumber;
|
|
34
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
35
|
+
position: z.ZodNumber;
|
|
36
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
37
|
+
position: z.ZodNumber;
|
|
38
|
+
}, z.ZodUnknown, "strip">>, z.objectOutputType<{
|
|
39
|
+
position: z.ZodNumber;
|
|
40
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
41
|
+
position: z.ZodNumber;
|
|
42
|
+
}, z.ZodUnknown, "strip">>;
|
|
43
|
+
declare const MetadataSchema: z.ZodObject<{
|
|
44
|
+
uniprot_id: z.ZodDefault<z.ZodString>;
|
|
45
|
+
description: z.ZodDefault<z.ZodString>;
|
|
46
|
+
reference: z.ZodDefault<z.ZodString>;
|
|
47
|
+
organism: z.ZodDefault<z.ZodString>;
|
|
48
|
+
}, "strict", z.ZodTypeAny, {
|
|
49
|
+
description: string;
|
|
50
|
+
uniprot_id: string;
|
|
51
|
+
reference: string;
|
|
52
|
+
organism: string;
|
|
53
|
+
}, {
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
uniprot_id?: string | undefined;
|
|
56
|
+
reference?: string | undefined;
|
|
57
|
+
organism?: string | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
export declare const A3InputSchema: z.ZodEffects<z.ZodObject<{
|
|
60
|
+
sequence: z.ZodEffects<z.ZodString, string, string>;
|
|
61
|
+
annotations: z.ZodDefault<z.ZodObject<{
|
|
62
|
+
site: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
63
|
+
index: z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>;
|
|
64
|
+
type: z.ZodDefault<z.ZodString>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
index: number[];
|
|
67
|
+
type: string;
|
|
68
|
+
}, {
|
|
69
|
+
index: number[];
|
|
70
|
+
type?: string | undefined;
|
|
71
|
+
}>>>;
|
|
72
|
+
region: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
73
|
+
index: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, [number, number], [number, number]>, "many">, [number, number][], [number, number][]>, [number, number][], [number, number][]>;
|
|
74
|
+
type: z.ZodDefault<z.ZodString>;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
index: [number, number][];
|
|
77
|
+
type: string;
|
|
78
|
+
}, {
|
|
79
|
+
index: [number, number][];
|
|
80
|
+
type?: string | undefined;
|
|
81
|
+
}>>>;
|
|
82
|
+
ptm: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
83
|
+
index: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, [number, number], [number, number]>, "many">, [number, number][], [number, number][]>, [number, number][], [number, number][]>, z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>]>;
|
|
84
|
+
type: z.ZodDefault<z.ZodString>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
index: number[] | [number, number][];
|
|
87
|
+
type: string;
|
|
88
|
+
}, {
|
|
89
|
+
index: number[] | [number, number][];
|
|
90
|
+
type?: string | undefined;
|
|
91
|
+
}>>>;
|
|
92
|
+
processing: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
93
|
+
index: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, [number, number], [number, number]>, "many">, [number, number][], [number, number][]>, [number, number][], [number, number][]>, z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>]>;
|
|
94
|
+
type: z.ZodDefault<z.ZodString>;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
index: number[] | [number, number][];
|
|
97
|
+
type: string;
|
|
98
|
+
}, {
|
|
99
|
+
index: number[] | [number, number][];
|
|
100
|
+
type?: string | undefined;
|
|
101
|
+
}>>>;
|
|
102
|
+
variant: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
103
|
+
position: z.ZodNumber;
|
|
104
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
105
|
+
position: z.ZodNumber;
|
|
106
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
107
|
+
position: z.ZodNumber;
|
|
108
|
+
}, z.ZodUnknown, "strip">>, z.objectOutputType<{
|
|
109
|
+
position: z.ZodNumber;
|
|
110
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
111
|
+
position: z.ZodNumber;
|
|
112
|
+
}, z.ZodUnknown, "strip">>, "many">>;
|
|
113
|
+
}, "strict", z.ZodTypeAny, {
|
|
114
|
+
variant: z.objectOutputType<{
|
|
115
|
+
position: z.ZodNumber;
|
|
116
|
+
}, z.ZodUnknown, "strip">[];
|
|
117
|
+
region: Record<string, {
|
|
118
|
+
index: [number, number][];
|
|
119
|
+
type: string;
|
|
120
|
+
}>;
|
|
121
|
+
site: Record<string, {
|
|
122
|
+
index: number[];
|
|
123
|
+
type: string;
|
|
124
|
+
}>;
|
|
125
|
+
ptm: Record<string, {
|
|
126
|
+
index: number[] | [number, number][];
|
|
127
|
+
type: string;
|
|
128
|
+
}>;
|
|
129
|
+
processing: Record<string, {
|
|
130
|
+
index: number[] | [number, number][];
|
|
131
|
+
type: string;
|
|
132
|
+
}>;
|
|
133
|
+
}, {
|
|
134
|
+
variant?: z.objectInputType<{
|
|
135
|
+
position: z.ZodNumber;
|
|
136
|
+
}, z.ZodUnknown, "strip">[] | undefined;
|
|
137
|
+
region?: Record<string, {
|
|
138
|
+
index: [number, number][];
|
|
139
|
+
type?: string | undefined;
|
|
140
|
+
}> | undefined;
|
|
141
|
+
site?: Record<string, {
|
|
142
|
+
index: number[];
|
|
143
|
+
type?: string | undefined;
|
|
144
|
+
}> | undefined;
|
|
145
|
+
ptm?: Record<string, {
|
|
146
|
+
index: number[] | [number, number][];
|
|
147
|
+
type?: string | undefined;
|
|
148
|
+
}> | undefined;
|
|
149
|
+
processing?: Record<string, {
|
|
150
|
+
index: number[] | [number, number][];
|
|
151
|
+
type?: string | undefined;
|
|
152
|
+
}> | undefined;
|
|
153
|
+
}>>;
|
|
154
|
+
metadata: z.ZodDefault<z.ZodObject<{
|
|
155
|
+
uniprot_id: z.ZodDefault<z.ZodString>;
|
|
156
|
+
description: z.ZodDefault<z.ZodString>;
|
|
157
|
+
reference: z.ZodDefault<z.ZodString>;
|
|
158
|
+
organism: z.ZodDefault<z.ZodString>;
|
|
159
|
+
}, "strict", z.ZodTypeAny, {
|
|
160
|
+
description: string;
|
|
161
|
+
uniprot_id: string;
|
|
162
|
+
reference: string;
|
|
163
|
+
organism: string;
|
|
164
|
+
}, {
|
|
165
|
+
description?: string | undefined;
|
|
166
|
+
uniprot_id?: string | undefined;
|
|
167
|
+
reference?: string | undefined;
|
|
168
|
+
organism?: string | undefined;
|
|
169
|
+
}>>;
|
|
170
|
+
}, "strict", z.ZodTypeAny, {
|
|
171
|
+
metadata: {
|
|
172
|
+
description: string;
|
|
173
|
+
uniprot_id: string;
|
|
174
|
+
reference: string;
|
|
175
|
+
organism: string;
|
|
176
|
+
};
|
|
177
|
+
sequence: string;
|
|
178
|
+
annotations: {
|
|
179
|
+
variant: z.objectOutputType<{
|
|
180
|
+
position: z.ZodNumber;
|
|
181
|
+
}, z.ZodUnknown, "strip">[];
|
|
182
|
+
region: Record<string, {
|
|
183
|
+
index: [number, number][];
|
|
184
|
+
type: string;
|
|
185
|
+
}>;
|
|
186
|
+
site: Record<string, {
|
|
187
|
+
index: number[];
|
|
188
|
+
type: string;
|
|
189
|
+
}>;
|
|
190
|
+
ptm: Record<string, {
|
|
191
|
+
index: number[] | [number, number][];
|
|
192
|
+
type: string;
|
|
193
|
+
}>;
|
|
194
|
+
processing: Record<string, {
|
|
195
|
+
index: number[] | [number, number][];
|
|
196
|
+
type: string;
|
|
197
|
+
}>;
|
|
198
|
+
};
|
|
199
|
+
}, {
|
|
200
|
+
sequence: string;
|
|
201
|
+
metadata?: {
|
|
202
|
+
description?: string | undefined;
|
|
203
|
+
uniprot_id?: string | undefined;
|
|
204
|
+
reference?: string | undefined;
|
|
205
|
+
organism?: string | undefined;
|
|
206
|
+
} | undefined;
|
|
207
|
+
annotations?: {
|
|
208
|
+
variant?: z.objectInputType<{
|
|
209
|
+
position: z.ZodNumber;
|
|
210
|
+
}, z.ZodUnknown, "strip">[] | undefined;
|
|
211
|
+
region?: Record<string, {
|
|
212
|
+
index: [number, number][];
|
|
213
|
+
type?: string | undefined;
|
|
214
|
+
}> | undefined;
|
|
215
|
+
site?: Record<string, {
|
|
216
|
+
index: number[];
|
|
217
|
+
type?: string | undefined;
|
|
218
|
+
}> | undefined;
|
|
219
|
+
ptm?: Record<string, {
|
|
220
|
+
index: number[] | [number, number][];
|
|
221
|
+
type?: string | undefined;
|
|
222
|
+
}> | undefined;
|
|
223
|
+
processing?: Record<string, {
|
|
224
|
+
index: number[] | [number, number][];
|
|
225
|
+
type?: string | undefined;
|
|
226
|
+
}> | undefined;
|
|
227
|
+
} | undefined;
|
|
228
|
+
}>, {
|
|
229
|
+
metadata: {
|
|
230
|
+
description: string;
|
|
231
|
+
uniprot_id: string;
|
|
232
|
+
reference: string;
|
|
233
|
+
organism: string;
|
|
234
|
+
};
|
|
235
|
+
sequence: string;
|
|
236
|
+
annotations: {
|
|
237
|
+
variant: z.objectOutputType<{
|
|
238
|
+
position: z.ZodNumber;
|
|
239
|
+
}, z.ZodUnknown, "strip">[];
|
|
240
|
+
region: Record<string, {
|
|
241
|
+
index: [number, number][];
|
|
242
|
+
type: string;
|
|
243
|
+
}>;
|
|
244
|
+
site: Record<string, {
|
|
245
|
+
index: number[];
|
|
246
|
+
type: string;
|
|
247
|
+
}>;
|
|
248
|
+
ptm: Record<string, {
|
|
249
|
+
index: number[] | [number, number][];
|
|
250
|
+
type: string;
|
|
251
|
+
}>;
|
|
252
|
+
processing: Record<string, {
|
|
253
|
+
index: number[] | [number, number][];
|
|
254
|
+
type: string;
|
|
255
|
+
}>;
|
|
256
|
+
};
|
|
257
|
+
}, {
|
|
258
|
+
sequence: string;
|
|
259
|
+
metadata?: {
|
|
260
|
+
description?: string | undefined;
|
|
261
|
+
uniprot_id?: string | undefined;
|
|
262
|
+
reference?: string | undefined;
|
|
263
|
+
organism?: string | undefined;
|
|
264
|
+
} | undefined;
|
|
265
|
+
annotations?: {
|
|
266
|
+
variant?: z.objectInputType<{
|
|
267
|
+
position: z.ZodNumber;
|
|
268
|
+
}, z.ZodUnknown, "strip">[] | undefined;
|
|
269
|
+
region?: Record<string, {
|
|
270
|
+
index: [number, number][];
|
|
271
|
+
type?: string | undefined;
|
|
272
|
+
}> | undefined;
|
|
273
|
+
site?: Record<string, {
|
|
274
|
+
index: number[];
|
|
275
|
+
type?: string | undefined;
|
|
276
|
+
}> | undefined;
|
|
277
|
+
ptm?: Record<string, {
|
|
278
|
+
index: number[] | [number, number][];
|
|
279
|
+
type?: string | undefined;
|
|
280
|
+
}> | undefined;
|
|
281
|
+
processing?: Record<string, {
|
|
282
|
+
index: number[] | [number, number][];
|
|
283
|
+
type?: string | undefined;
|
|
284
|
+
}> | undefined;
|
|
285
|
+
} | undefined;
|
|
286
|
+
}>;
|
|
287
|
+
export type A3Data = z.infer<typeof A3InputSchema>;
|
|
288
|
+
export type MetadataData = z.infer<typeof MetadataSchema>;
|
|
289
|
+
export type VariantData = z.infer<typeof VariantSchema>;
|
|
290
|
+
export type SiteEntryData = z.infer<typeof SiteEntrySchema>;
|
|
291
|
+
export type RegionEntryData = z.infer<typeof RegionEntrySchema>;
|
|
292
|
+
export type FlexEntryData = z.infer<typeof FlexEntrySchema>;
|
|
293
|
+
export {};
|
|
294
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwCxB,QAAA,MAAM,eAAe;;;;;;;;;EAGnB,CAAC;AAEH,QAAA,MAAM,iBAAiB;;;;;;;;;EAGrB,CAAC;AAEH,QAAA,MAAM,eAAe;;;;;;;;;EAGnB,CAAC;AAKH,QAAA,MAAM,aAAa;;;;;;;;;;0BAGyE,CAAC;AAgB7F,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;EAOT,CAAC;AAIZ,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6DtB,CAAC;AAIL,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACnD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACxD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC5D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isJsonCompatible, sortDedup, sortRanges } from "./normalize";
|
|
3
|
+
// ── Primitives ────────────────────────────────────────────────────────────────
|
|
4
|
+
// 1-based positive integer position
|
|
5
|
+
const PositionSchema = z.number().int().min(1);
|
|
6
|
+
// Sorted, deduplicated array of positions
|
|
7
|
+
const PositionsSchema = z.array(PositionSchema).transform(sortDedup);
|
|
8
|
+
// Inclusive [start, end] range tuple, start < end
|
|
9
|
+
const RangeTupleSchema = z
|
|
10
|
+
.tuple([PositionSchema, PositionSchema])
|
|
11
|
+
.refine(([s, e]) => s < e, { message: "start must be < end" });
|
|
12
|
+
// Sorted array of ranges; overlapping ranges are rejected
|
|
13
|
+
const RangesSchema = z
|
|
14
|
+
.array(RangeTupleSchema)
|
|
15
|
+
.transform(sortRanges)
|
|
16
|
+
.superRefine((ranges, ctx) => {
|
|
17
|
+
let prev;
|
|
18
|
+
for (const curr of ranges) {
|
|
19
|
+
if (prev !== undefined && curr[0] <= prev[1]) {
|
|
20
|
+
ctx.addIssue({
|
|
21
|
+
code: z.ZodIssueCode.custom,
|
|
22
|
+
message: `ranges [${prev[0]},${prev[1]}] and [${curr[0]},${curr[1]}] overlap`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
prev = curr;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// ── Annotation entry schemas ──────────────────────────────────────────────────
|
|
29
|
+
//
|
|
30
|
+
// Canonical form only: { index, type }.
|
|
31
|
+
// Site: always positions. Region: always ranges.
|
|
32
|
+
// PTM / Processing: either positions or ranges (never mixed within one entry).
|
|
33
|
+
// Union order matters — ranges branch is tried first (more specific).
|
|
34
|
+
const SiteEntrySchema = z.object({
|
|
35
|
+
index: PositionsSchema,
|
|
36
|
+
type: z.string().default(""),
|
|
37
|
+
});
|
|
38
|
+
const RegionEntrySchema = z.object({
|
|
39
|
+
index: RangesSchema,
|
|
40
|
+
type: z.string().default(""),
|
|
41
|
+
});
|
|
42
|
+
const FlexEntrySchema = z.object({
|
|
43
|
+
index: z.union([RangesSchema, PositionsSchema]),
|
|
44
|
+
type: z.string().default(""),
|
|
45
|
+
});
|
|
46
|
+
// ── Variant ───────────────────────────────────────────────────────────────────
|
|
47
|
+
// Every variant requires `position`; additional JSON-compatible fields are allowed.
|
|
48
|
+
const VariantSchema = z
|
|
49
|
+
.object({ position: PositionSchema })
|
|
50
|
+
.catchall(z.unknown())
|
|
51
|
+
.refine((v) => isJsonCompatible(v), { message: "variant fields must be JSON-compatible" });
|
|
52
|
+
// ── Annotation families ───────────────────────────────────────────────────────
|
|
53
|
+
const AnnotationsSchema = z
|
|
54
|
+
.object({
|
|
55
|
+
site: z.record(z.string().min(1), SiteEntrySchema).default({}),
|
|
56
|
+
region: z.record(z.string().min(1), RegionEntrySchema).default({}),
|
|
57
|
+
ptm: z.record(z.string().min(1), FlexEntrySchema).default({}),
|
|
58
|
+
processing: z.record(z.string().min(1), FlexEntrySchema).default({}),
|
|
59
|
+
variant: z.array(VariantSchema).default([]),
|
|
60
|
+
})
|
|
61
|
+
.strict();
|
|
62
|
+
// ── Metadata ──────────────────────────────────────────────────────────────────
|
|
63
|
+
const MetadataSchema = z
|
|
64
|
+
.object({
|
|
65
|
+
uniprot_id: z.string().default(""),
|
|
66
|
+
description: z.string().default(""),
|
|
67
|
+
reference: z.string().default(""),
|
|
68
|
+
organism: z.string().default(""),
|
|
69
|
+
})
|
|
70
|
+
.strict();
|
|
71
|
+
// ── Root schema ───────────────────────────────────────────────────────────────
|
|
72
|
+
export const A3InputSchema = z
|
|
73
|
+
.object({
|
|
74
|
+
sequence: z
|
|
75
|
+
.string()
|
|
76
|
+
.min(2, "sequence must be at least 2 characters")
|
|
77
|
+
.regex(/^[A-Za-z*]+$/, "sequence must contain only amino acid letters [A-Za-z] or '*'")
|
|
78
|
+
.transform((s) => s.toUpperCase()),
|
|
79
|
+
annotations: AnnotationsSchema.default({
|
|
80
|
+
site: {},
|
|
81
|
+
region: {},
|
|
82
|
+
ptm: {},
|
|
83
|
+
processing: {},
|
|
84
|
+
variant: [],
|
|
85
|
+
}),
|
|
86
|
+
metadata: MetadataSchema.default({}),
|
|
87
|
+
})
|
|
88
|
+
.strict()
|
|
89
|
+
.superRefine((data, ctx) => {
|
|
90
|
+
const len = data.sequence.length;
|
|
91
|
+
const boundsMsg = (pos) => `position ${pos} is out of bounds for sequence of length ${len} (must be 1–${len})`;
|
|
92
|
+
const checkPos = (pos, path) => {
|
|
93
|
+
if (pos < 1 || pos > len)
|
|
94
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, message: boundsMsg(pos), path });
|
|
95
|
+
};
|
|
96
|
+
const checkIndex = (index, basePath) => {
|
|
97
|
+
if (index.length === 0)
|
|
98
|
+
return;
|
|
99
|
+
if (Array.isArray(index[0])) {
|
|
100
|
+
let i = 0;
|
|
101
|
+
for (const [s, e] of index) {
|
|
102
|
+
checkPos(s, [...basePath, i, 0]);
|
|
103
|
+
checkPos(e, [...basePath, i, 1]);
|
|
104
|
+
i++;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
let i = 0;
|
|
109
|
+
for (const pos of index) {
|
|
110
|
+
checkPos(pos, [...basePath, i]);
|
|
111
|
+
i++;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
for (const [name, entry] of Object.entries(data.annotations.site)) {
|
|
116
|
+
checkIndex(entry.index, ["annotations", "site", name, "index"]);
|
|
117
|
+
}
|
|
118
|
+
for (const [name, entry] of Object.entries(data.annotations.region)) {
|
|
119
|
+
checkIndex(entry.index, ["annotations", "region", name, "index"]);
|
|
120
|
+
}
|
|
121
|
+
for (const [name, entry] of Object.entries(data.annotations.ptm)) {
|
|
122
|
+
checkIndex(entry.index, ["annotations", "ptm", name, "index"]);
|
|
123
|
+
}
|
|
124
|
+
for (const [name, entry] of Object.entries(data.annotations.processing)) {
|
|
125
|
+
checkIndex(entry.index, ["annotations", "processing", name, "index"]);
|
|
126
|
+
}
|
|
127
|
+
data.annotations.variant.forEach((v, i) => {
|
|
128
|
+
checkPos(v.position, ["annotations", "variant", i, "position"]);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtE,iFAAiF;AAEjF,oCAAoC;AACpC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAE/C,0CAA0C;AAC1C,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,SAA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|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Annotated Amino Acid (A3) format — TypeScript implementation",
|
|
5
|
+
"license": "MPL-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/rtemis-org/a3",
|
|
9
|
+
"directory": "typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc -p tsconfig.build.json",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"check": "biome check src tests"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"zod": "^3.23.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@biomejs/biome": "^1.9.0",
|
|
35
|
+
"@types/node": "^25.5.0",
|
|
36
|
+
"typescript": "^5.5.0",
|
|
37
|
+
"vitest": "^2.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|