Skip to content
Snippets Groups Projects
Commit 93e107f3 authored by yakomaxa's avatar yakomaxa
Browse files

give pymol the ability to deal with negatively indexed residue numbering

parent 655b334b
No related branches found
No related tags found
No related merge requests found
...@@ -14,31 +14,65 @@ const reFloat = /[-+]?[0-9]*\.?[0-9]+/; ...@@ -14,31 +14,65 @@ const reFloat = /[-+]?[0-9]*\.?[0-9]+/;
function atomNameListMap(x: string) { return x.split('+').map(B.atomName); } function atomNameListMap(x: string) { return x.split('+').map(B.atomName); }
function listMap(x: string) { return x.split('+').map(x => x.replace(/^["']|["']$/g, '')); } function listMap(x: string) { return x.split('+').map(x => x.replace(/^["']|["']$/g, '')); }
function rangeMap(x: string) {
const [min, max] = x.split('-').map(x => parseInt(x));
return { min, max };
}
function listOrRangeMap(x: string) { function listOrRangeMap(x: string) {
// cases
if (x.includes('-') && x.includes('+')) { if (x.includes('-') && x.includes('+')) {
const pSplit = x.split('+').map(x => x.replace(/^["']|["']$/g, '')); const pSplit = x.split('+').map(x => x.replace(/^["']|["']$/g, ''));
const res: number[] = []; const res: number[] = [];
pSplit.forEach(x => { pSplit.forEach(x => {
if (x.includes('-')) { if (x.includes('-') && !x.startsWith("-")) {
const [min, max] = x.split('-').map(x=>parseInt(x)); const [min, max] = x.split('-').map(x=>parseInt(x));
for (let i = min; i <= max; i++) { for (let i = min; i <= max; i++) {
res.push(i); res.push(i);
} }
} else { }else if (x.includes('-') && x.startsWith("-") && x.match(/[0-9]+-[-0-9]+/)) {
const min = -parseInt(x.split('-')[1]);
var max ;
if (x.includes('--')) {
max = -parseInt(x.split('-')[3])
}else{
max = parseInt(x.split('-')[2])
}
for (let i = min; i <= max; i++) {
res.push(i);
}
}else if (x.includes('-') && x.startsWith("-") && !x.match(/[0-9]+-[0-9]+/)) {
res.push(parseInt(x));
}else{
res.push(parseInt(x)); res.push(parseInt(x));
} }
}); });
return res; return res;
} else if (x.includes('-') && !x.includes('+')) { } else if (x.includes('-') && !x.includes('+')) {
return rangeMap(x); const res: number[] = [];
if (!x.startsWith("-")) {
const [min, max] = x.split('-').map(x=>parseInt(x));
for (let i = min; i <= max; i++) {
res.push(i);
}
}else if (x.startsWith("-") && x.match(/[0-9]+-[-0-9]+/)) {
const min = -parseInt(x.split('-')[1]);
console.log(min)
var max ;
if (x.includes('--')) {
max = -parseInt(x.split('-')[3])
}else{
max = parseInt(x.split('-')[2])
}
for (let i = min; i <= max; i++) {
res.push(i);
}
}else if (x.startsWith("-") && !x.match(/[0-9]+-[0-9]+/)) {
res.push(parseInt(x));
}else{
res.push(parseInt(x));
}
return res;
} else if (!x.includes('-') && x.includes('+')) { } else if (!x.includes('-') && x.includes('+')) {
return listMap(x).map(x => parseInt(x)); return listMap(x).map(x => parseInt(x));
} else { } else {
return listMap(x).map(x => parseInt(x)); return [parseInt(x)];
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment