Commit cdc12cd9 authored by Mathieu Giraud's avatar Mathieu Giraud

js/clone.js: .getShortName(), shorten successive identical locus

IGHV3-11*03 ... IGHD6-13*01 ... becomes IGHV3-11*03 ... D6-13*01
parent 8a61d635
......@@ -79,17 +79,30 @@ Clone.prototype = {
* */
REGEX_N: /^(\d*)\/([ACGT]*)\/(\d*)$/, // 6/ACCAT/
REGEX_GENE: /(IGH|IGK|IGL|TRA|TRB|TRG|TRD)([\w-*]*)$/, // IGHV3-11*03
getShortName: function () {
name_items = this.getName().split(' ')
short_name_items = []
last_locus = ''
for (var i = 0; i < name_items.length; i++) {
s = name_items[i]
console.log('>' + s);
// Shorten IGHV3-11*03 ... IGHD6-13*01 ... IGHJ4*02 into IGHV3-11*03 ... D6-13*01 ... J4*02
z = s.match(this.REGEX_GENE);
if (z)
{
locus = (z[1] == last_locus) ? '' : z[1]
short_name_items.push(locus + z[2])
last_locus = z[1]
continue
}
// Shorten 6/ACCAT/ into 6/5/0
z = s.match(this.REGEX_N);
if (z)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment