@rnacanvas/search 1.2.0 → 1.2.1

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/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # Installation
2
+
3
+ With `npm`:
4
+
5
+ ```
6
+ npm install @rnacanvas/search
7
+ ```
8
+
9
+ # Usage
10
+
11
+ All exports of this package can be accessed as named imports.
12
+
13
+ ```javascript
14
+ // an example import
15
+ import { SequenceCharacter } from '@rnacanvas/search';
16
+ ```
17
+
18
+ ## `class SequenceCharacter`
19
+
20
+ Represents a character in a sequence.
21
+
22
+ ```javascript
23
+ var A = new SequenceCharacter('A');
24
+
25
+ A.toString(); // "A"
26
+
27
+ A.matches('A'); // true
28
+ A.matches('G'); // false
29
+
30
+ A.complements('U'); // true
31
+ A.complements('T'); // true
32
+ A.complements('G'); // false
33
+
34
+ // case doesn't matter
35
+ A.matches('a'); // true
36
+ A.complements('u'); // true
37
+
38
+ // IUPAC codes are recognized
39
+ A.matches('R'); // true
40
+ ```
41
+
42
+ This constructor will throw for strings that are not composed of a single character.
43
+
44
+ ```javascript
45
+ // empty string
46
+ new SequenceCharacter(''); // throws
47
+
48
+ // more than one character
49
+ new SequenceCharacter('AG'); // throws
50
+ new SequenceCharacter('asdf'); // throws
51
+ ```
52
+
53
+ Any character may be input to the constructor, though.
54
+
55
+ ### `toString()`
56
+
57
+ Simply returns the character as a string.
58
+
59
+ ```javascript
60
+ var A = new SequenceCharacter('A');
61
+ A.toString(); // "A"
62
+
63
+ var R = new SequenceCharacter('R');
64
+ R.toString(); // "R"
65
+ ```
66
+
67
+ ### `matches()`
68
+
69
+ Returns `true` if the character matches the input character.
70
+
71
+ ```javascript
72
+ var A = new SequenceCharacter('A');
73
+
74
+ A.matches('A'); // true
75
+ A.matches('C'); // false
76
+
77
+ // case doesn't matter
78
+ A.matches('a'); // true
79
+
80
+ // works for sequence character instances too
81
+ A.matches(new SequenceCharacter('A')); // true
82
+ ```
83
+
84
+ [IUPAC nucleic acid codes](https://www.bioinformatics.org/sms/iupac.html) are recognized.
85
+
86
+ ```javascript
87
+ var A = new SequenceCharacter('A');
88
+
89
+ A.matches('R'); // true
90
+ A.matches('Y'); // false
91
+
92
+ var N = new SequenceCharacter('N');
93
+
94
+ // the any character matches any non-gap character
95
+ N.matches('A'); // true
96
+ N.matches('p'); // true
97
+
98
+ var period = new SequenceCharacter('.');
99
+ var dash = new SequenceCharacter('-');
100
+
101
+ // gap characters only match other gap characters
102
+ period.matches('.'); // true
103
+ dash.matches('-'); // true
104
+ period.matches('N'); // false
105
+ ```
106
+
107
+ Will throw for empty strings and strings containing more than one character.
108
+
109
+ ```javascript
110
+ var A = new SequenceCharacter('A');
111
+
112
+ // empty string
113
+ A.matches(''); // throws
114
+
115
+ // strings containing more than one character
116
+ A.matches('AG'); // throws
117
+ A.matches('asdf'); // throws
118
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"SequenceCharacter.d.ts","sourceRoot":"","sources":["../src/SequenceCharacter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,iBAAiB;;gBAGhB,SAAS,EAAE,MAAM;IAU7B,QAAQ,IAAI,MAAM;IAIlB,OAAO,CAAC,cAAc,EAAE,iBAAiB,GAAG,MAAM,GAAG,OAAO;IAwB5D,WAAW,CAAC,cAAc,EAAE,iBAAiB,GAAG,MAAM,GAAG,OAAO;CAiCjE"}
1
+ {"version":3,"file":"SequenceCharacter.d.ts","sourceRoot":"","sources":["../src/SequenceCharacter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,iBAAiB;;gBAGhB,SAAS,EAAE,MAAM;IAU7B,QAAQ,IAAI,MAAM;IAIlB,OAAO,CAAC,cAAc,EAAE,iBAAiB,GAAG,MAAM,GAAG,OAAO;IA0B5D,WAAW,CAAC,cAAc,EAAE,iBAAiB,GAAG,MAAM,GAAG,OAAO;CAmCjE"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.search=t():e.search=t()}(this,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{SequenceCharacter:()=>n});var r,o=function(e,t,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(e):o?o.value:t.get(e)};class n{constructor(e){if(r.set(this,void 0),0==e.length)throw new Error("Character cannot be an empty string.");if(e.length>1)throw new Error("Character must be a single character.");!function(e,t,r,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,r):n?n.value=r:t.set(e,r)}(this,r,e,"f")}toString(){return o(this,r,"f")}matches(e){var t,n;if("string"!=typeof e&&(e=e.toString()),1!=e.length)return!1;let a=o(this,r,"f").toUpperCase();return e=e.toUpperCase(),"N"===a||"N"===e||(a in i?null!==(n=null===(t=i[a])||void 0===t?void 0:t.includes(e))&&void 0!==n&&n:a===e)}complements(e){var t,n;if("string"!=typeof e&&(e=e.toString()),1!=e.length)return!1;let i=o(this,r,"f").toUpperCase();e=e.toUpperCase();let s=[...".-"];return!(!s.includes(i)||!s.includes(e))||!s.includes(i)&&!s.includes(e)&&("N"===i&&!s.includes(e)||"N"===e&&!s.includes(i)||i in a&&null!==(n=null===(t=a[i])||void 0===t?void 0:t.includes(e))&&void 0!==n&&n)}}r=new WeakMap;const i={A:[..."A"],C:[..."C"],G:[..."G"],U:[..."UT"],T:[..."TU"],R:[..."AG"],Y:[..."CUT"],S:[..."GC"],W:[..."AUT"],K:[..."GUT"],M:[..."AC"],B:[..."CGUTYSK"],D:[..."AGUTRWK"],H:[..."ACUTYWM"],V:[..."ACGRSM"],".":[...".-"],"-":[..."-."]},a={A:[..."UT"],C:[..."G"],G:[..."CUT"],U:[..."AG"],T:[..."AG"]};return t})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.search=t():e.search=t()}(this,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{SequenceCharacter:()=>n});var r,o=function(e,t,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(e):o?o.value:t.get(e)};class n{constructor(e){if(r.set(this,void 0),0==e.length)throw new Error("Character cannot be an empty string.");if(e.length>1)throw new Error("Character must be a single character.");!function(e,t,r,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,r):n?n.value=r:t.set(e,r)}(this,r,e,"f")}toString(){return o(this,r,"f")}matches(e){var t,n;if("string"!=typeof e&&(e=e.toString()),0==e.length)throw new Error("Other character cannot be an empty string.");if(e.length>1)throw new Error("Other character cannot be multiple characters.");let i=o(this,r,"f").toUpperCase();return e=e.toUpperCase(),"N"===i||"N"===e||(i in a?null!==(n=null===(t=a[i])||void 0===t?void 0:t.includes(e))&&void 0!==n&&n:i===e)}complements(e){var t,n;if("string"!=typeof e&&(e=e.toString()),0==e.length)throw new Error("Other character cannot be an empty string.");if(e.length>1)throw new Error("Other character cannot be multiple characters.");let a=o(this,r,"f").toUpperCase();e=e.toUpperCase();let c=[...".-"];return!(!c.includes(a)||!c.includes(e))||!c.includes(a)&&!c.includes(e)&&("N"===a&&!c.includes(e)||"N"===e&&!c.includes(a)||a in i&&null!==(n=null===(t=i[a])||void 0===t?void 0:t.includes(e))&&void 0!==n&&n)}}r=new WeakMap;const a={A:[..."A"],C:[..."C"],G:[..."G"],U:[..."UT"],T:[..."TU"],R:[..."AG"],Y:[..."CUT"],S:[..."GC"],W:[..."AUT"],K:[..."GUT"],M:[..."AC"],B:[..."CGUTYSK"],D:[..."AGUTRWK"],H:[..."ACUTYWM"],V:[..."ACGRSM"],".":[...".-"],"-":[..."-."]},i={A:[..."UT"],C:[..."G"],G:[..."CUT"],U:[..."AG"],T:[..."AG"]};return t})());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnacanvas/search",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Find motifs",
5
5
  "repository": {
6
6
  "type": "git",