@rnacanvas/search 1.2.3 → 1.2.4

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.
Files changed (2) hide show
  1. package/README.md +77 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -50,18 +50,19 @@ new SequenceCharacter('AG'); // throws
50
50
  new SequenceCharacter('asdf'); // throws
51
51
  ```
52
52
 
53
- Any character may be input to the constructor, though.
53
+ A `SequenceCharacter` instance may be created for any character, though.
54
54
 
55
55
  ### `toString()`
56
56
 
57
- Simply returns the character as a string.
57
+ Returns the character as a string.
58
58
 
59
59
  ```javascript
60
60
  var A = new SequenceCharacter('A');
61
61
  A.toString(); // "A"
62
62
 
63
- var R = new SequenceCharacter('R');
64
- R.toString(); // "R"
63
+ // preserves case
64
+ var r = new SequenceCharacter('r');
65
+ r.toString(); // "r"
65
66
  ```
66
67
 
67
68
  ### `matches()`
@@ -95,16 +96,19 @@ var N = new SequenceCharacter('N');
95
96
  N.matches('A'); // true
96
97
  N.matches('p'); // true
97
98
 
99
+ // gap characters
98
100
  var period = new SequenceCharacter('.');
99
101
  var dash = new SequenceCharacter('-');
100
102
 
101
103
  // gap characters only match other gap characters
102
104
  period.matches('.'); // true
103
105
  dash.matches('-'); // true
104
- period.matches('N'); // false
106
+
107
+ N.matches('.'); // false
108
+ N.matches('-'); // false
105
109
  ```
106
110
 
107
- Will throw for empty strings and strings containing more than one character.
111
+ Throws for empty strings and strings containing more than one character.
108
112
 
109
113
  ```javascript
110
114
  var A = new SequenceCharacter('A');
@@ -116,3 +120,70 @@ A.matches(''); // throws
116
120
  A.matches('AG'); // throws
117
121
  A.matches('asdf'); // throws
118
122
  ```
123
+
124
+ ### `complements()`
125
+
126
+ Returns `true` if the character complements the specified character.
127
+
128
+ ```javascript
129
+ var A = new SequenceCharacter('A');
130
+
131
+ A.complements('U'); // true
132
+ A.complements('A'); // false
133
+
134
+ // T and U are interchangeable
135
+ A.complements('T'); // true
136
+
137
+ // case doesn't matter
138
+ A.complements('u'); // true
139
+
140
+ // sequence character instances can also be input
141
+ A.complements(new SequenceCharacter('U')); // true
142
+ ```
143
+
144
+ [IUPAC nucleic acid codes](https://www.bioinformatics.org/sms/iupac.html) are recognized.
145
+
146
+ ```javascript
147
+ var G = new SequenceCharacter('G');
148
+
149
+ // since G can pair with C, U and T
150
+ G.complements('Y'); // true
151
+
152
+ var U = new SequenceCharacter('U');
153
+
154
+ // since U can pair with A or G
155
+ U.complements('R'); // true
156
+
157
+ var N = new SequenceCharacter('N');
158
+
159
+ // the any character complements any non-gap character
160
+ N.complements('A'); // true
161
+
162
+ // gap characters
163
+ var period = new SequenceCharacter('.');
164
+ var dash = new SequenceCharacter('-');
165
+
166
+ // gap characters only complement other gap characters
167
+ period.complements('.'); // true
168
+ period.complements('-'); // true
169
+
170
+ N.complements('.'); // false
171
+ N.complements('-'); // false
172
+ ```
173
+
174
+ Note that the special IUPAC codes
175
+ `S`, `W`, `K`, `M`, `B`, `D`, `H` and `V`
176
+ have no complements.
177
+
178
+ This method throws for empty strings and strings containing more than one character.
179
+
180
+ ```javascript
181
+ var A = new SequenceCharacter('A');
182
+
183
+ // empty string
184
+ A.complements(''); // throws
185
+
186
+ // strings containing more than one character
187
+ A.complements('AG'); // throws
188
+ A.complements('asdf'); // throws
189
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnacanvas/search",
3
- "version": "1.2.3",
4
- "description": "Find motifs",
3
+ "version": "1.2.4",
4
+ "description": "Find motifs and complements",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/pzhaojohnson/rnacanvas.search.git"