diff --git a/.eslintrc.json b/.eslintrc.json index 28e80614867167fe9c80bb988dc5fa9114552072..bef255fae52e4dccb7bd4ac7908ec12c3e47cf10 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -55,6 +55,9 @@ "error", "1tbs", { "allowSingleLine": true } ], + "comma-spacing": "off", + "@typescript-eslint/comma-spacing": "error", + "space-infix-ops": "error", "comma-dangle": "off", "eqeqeq": [ "error", diff --git a/src/apps/viewer/extensions/cellpack/color.ts b/src/apps/viewer/extensions/cellpack/color.ts index 7b3b333d103e797f492a871ad4ab266eb8ccd12b..d14de313246ea5b84d25911a8e3b7c07ea8e39f5 100644 --- a/src/apps/viewer/extensions/cellpack/color.ts +++ b/src/apps/viewer/extensions/cellpack/color.ts @@ -52,7 +52,7 @@ export function CellPackColorTheme(ctx: ThemeDataContext, props: PD.Values<CellP }}) legend = palette.legend const modelColor = new Map<number, Color>() - for (let i = 0, il = models.length; i <il; ++i) { + for (let i = 0, il = models.length; i < il; ++i) { const idx = models[i].trajectoryInfo.index; modelColor.set(models[i].trajectoryInfo.index, palette.color(idx)) } diff --git a/src/apps/viewer/extensions/cellpack/curve.ts b/src/apps/viewer/extensions/cellpack/curve.ts index 4b789f7a5cb1755033270839266762a1686da4eb..6a31ac5a78a37700e2d995cba37f9a134407eba2 100644 --- a/src/apps/viewer/extensions/cellpack/curve.ts +++ b/src/apps/viewer/extensions/cellpack/curve.ts @@ -119,7 +119,7 @@ function GetSmoothNormals(points: Vec3[]) { p0 = points[i - 1] p1 = points[i] p2 = points[i + 1] - const t = Vec3.normalize(tmpV1, Vec3.sub(tmpV1, p2 , p0)) + const t = Vec3.normalize(tmpV1, Vec3.sub(tmpV1, p2, p0)) const b = Vec3.normalize(tmpV2, Vec3.cross(tmpV2, t, prevV)) const n = Vec3.normalize(Vec3(), Vec3.cross(tmpV3, t, b)) Vec3.negate(n, n) @@ -128,8 +128,8 @@ function GetSmoothNormals(points: Vec3[]) { } const last = Vec3() Vec3.normalize(last, Vec3.cross(last, - Vec3.sub(tmpV1, points[nP - 3], points[nP-2]), - Vec3.sub(tmpV2, points[nP-2] , points[nP-1])) + Vec3.sub(tmpV1, points[nP - 3], points[nP - 2]), + Vec3.sub(tmpV2, points[nP - 2], points[nP - 1])) ) smoothNormals.push(last) return smoothNormals; @@ -168,8 +168,8 @@ function GetMiniFrame(points: Vec3[], normals: Vec3[]) { const t0 = Vec3.normalize(mfTmpV1, Vec3.sub(mfTmpV1, points[1], points[0])) frames.push(getFrame(normals[0], t0)) - for (let i = 0; i< points.length-2; ++i) { - const t2 = Vec3.normalize(mfTmpV1, Vec3.sub(mfTmpV1, points[i+2], points[i+1])) + for (let i = 0; i < points.length - 2; ++i) { + const t2 = Vec3.normalize(mfTmpV1, Vec3.sub(mfTmpV1, points[i + 2], points[i + 1])) const v1 = Vec3.sub(mfTmpV2, points[i + 1], points[i]) // this is tangeant const c1 = Vec3.dot(v1, v1) // compute r_i^L = R_1 * r_i @@ -179,10 +179,10 @@ function GetMiniFrame(points: Vec3[], normals: Vec3[]) { const v1t = Vec3.scale(mfTmpV5, v1, (2.0 / c1) * Vec3.dot(v1, frames[i].t)) const tan_L_i = Vec3.sub(mfTmpV6, frames[i].t, v1t) // # compute reflection vector of R_2 - const v2 = Vec3.sub(mfTmpV7, t2 , tan_L_i) + const v2 = Vec3.sub(mfTmpV7, t2, tan_L_i) const c2 = Vec3.dot(v2, v2) // compute r_(i+1) = R_2 * r_i^L - const v2l = Vec3.scale(mfTmpV8, v1, (2.0/c2) * Vec3.dot(v2, ref_L_i)) + const v2l = Vec3.scale(mfTmpV8, v1, (2.0 / c2) * Vec3.dot(v2, ref_L_i)) const ref_next = Vec3.sub(mfTmpV9, ref_L_i, v2l) // ref_L_i - (2 / c2) * v2.dot(ref_L_i) * v2 frames.push(getFrame(ref_next, t2)) // frames.append(Frame(ref_next, tangents[i+1])) } @@ -199,13 +199,13 @@ export function getMatFromResamplePoints(points: NumberArray, segmentLength: num const limit = npoints const transforms: Mat4[] = [] const pti = Vec3.copy(rpTmpVec1, new_points[0]); - for (let i = 0; i<npoints-2; ++i) { - const pti1: Vec3 = new_points[i+1] // Vec3.create(points[(i+1)*3],points[(i+1)*3+1],points[(i+1)*3+2]); + for (let i = 0; i < npoints - 2; ++i) { + const pti1: Vec3 = new_points[i + 1] // Vec3.create(points[(i+1)*3],points[(i+1)*3+1],points[(i+1)*3+2]); const d = Vec3.distance(pti, pti1) if (d >= segmentLength) { // use twist or random? const quat = Quat.rotationTo(Quat.zero(), Vec3.create(0, 0, 1), frames[i].t) // Quat.rotationTo(Quat.zero(), Vec3.create(0,0,1),new_normal[i]);//Quat.rotationTo(Quat.zero(), Vec3.create(0,0,1),direction);new_normal - const rq = Quat.setAxisAngle(Quat.zero(), frames[i].t, Math.random()*3.60 ) // Quat.setAxisAngle(Quat.zero(),direction, Math.random()*3.60 );//Quat.identity();// + const rq = Quat.setAxisAngle(Quat.zero(), frames[i].t, Math.random() * 3.60 ) // Quat.setAxisAngle(Quat.zero(),direction, Math.random()*3.60 );//Quat.identity();// const m = Mat4.fromQuat(Mat4.zero(), Quat.multiply(Quat.zero(), rq, quat)) // Mat4.fromQuat(Mat4.zero(),Quat.multiply(Quat.zero(),quat1,quat2));//Mat4.fromQuat(Mat4.zero(),quat);//Mat4.identity();//Mat4.fromQuat(Mat4.zero(),Quat.multiply(Quat.zero(),rq,quat)); // let pos:Vec3 = Vec3.add(Vec3.zero(),pti1,pti) // pos = Vec3.scale(pos,pos,1.0/2.0); diff --git a/src/apps/viewer/extensions/cellpack/model.ts b/src/apps/viewer/extensions/cellpack/model.ts index 5ef48f02eff4e741a53a8b8f59350e9f5c413b96..6dbc3b59acfbbaff066231ade01a081eb10fc9fa 100644 --- a/src/apps/viewer/extensions/cellpack/model.ts +++ b/src/apps/viewer/extensions/cellpack/model.ts @@ -49,7 +49,6 @@ async function getModel(id: string, model_id: number, baseUrl: string, file?: Fi throw new Error(`unsupported file type '${file.name}'`) } } else if (id.match(/^[1-9][a-zA-Z0-9]{3,3}$/i)) { - // return const cif = await getFromPdb(id) model = (await trajectoryFromMmCIF(cif).run())[model_id] } else { @@ -68,7 +67,7 @@ async function getStructure(model: Model, source: IngredientSource, props: { ass } let query; if (source.selection){ - const asymIds: string[] = source.selection.replace(' :','').split(' or') + const asymIds: string[] = source.selection.replace(' :', '').split(' or') query = MS.struct.modifier.union([ MS.struct.generator.atomGroups({ 'entity-test': MS.core.rel.eq([MS.ammp('entityType'), 'polymer']), @@ -102,7 +101,7 @@ function getTransformLegacy(trans: Vec3, rot: Quat) { function getTransform(trans: Vec3, rot: Quat) { const q: Quat = Quat.create(rot[0], rot[1], rot[2], rot[3]) const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q) - const p: Vec3 = Vec3.create(trans[0],trans[1],trans[2]) + const p: Vec3 = Vec3.create(trans[0], trans[1], trans[2]) Mat4.setTranslation(m, p) return m } @@ -116,7 +115,11 @@ function getResultTransforms(results: Ingredient['results'], legacy: boolean) { function getCurveTransforms(ingredient: Ingredient) { const n = ingredient.nbCurve || 0 const instances: Mat4[] = [] - const segmentLength = (ingredient.radii)? ((ingredient.radii[0].radii)?ingredient.radii[0].radii[0]*2.0:3.4):3.4; + const segmentLength = ingredient.radii + ? (ingredient.radii[0].radii + ? ingredient.radii[0].radii[0] * 2.0 + : 3.4) + : 3.4; for (let i = 0; i < n; ++i) { const cname = `curve${i}` if (!(cname in ingredient)) { @@ -130,7 +133,7 @@ function getCurveTransforms(ingredient: Ingredient) { } const points = new Float32Array(_points.length * 3) for (let i = 0, il = _points.length; i < il; ++i) Vec3.toArray(_points[i], points, i * 3) - const newInstances = getMatFromResamplePoints(points,segmentLength) + const newInstances = getMatFromResamplePoints(points, segmentLength) instances.push(...newInstances) } @@ -273,8 +276,8 @@ async function getIngredientStructure(ingredient: Ingredient, baseUrl: string, i } // model id in case structure is NMR - const model_id = (ingredient.source.model)? parseInt(ingredient.source.model) : 0; - const model = await getModel(source.pdb || name,model_id, baseUrl, file) + const model_id = (ingredient.source.model) ? parseInt(ingredient.source.model) : 0; + const model = await getModel(source.pdb || name, model_id, baseUrl, file) if (!model) return if (nbCurve) { @@ -288,35 +291,35 @@ async function getIngredientStructure(ingredient: Ingredient, baseUrl: string, i bu = bu.slice(2) } } - let structure = await getStructure(model,source, { assembly: bu }) + let structure = await getStructure(model, source, { assembly: bu }) // transform with offset and pcp let legacy: boolean = true if (ingredient.offset || ingredient.principalAxis){ // center the structure - legacy=false + legacy = false const boundary = structure.boundary let structureCenter: Vec3 = Vec3.zero() - Vec3.negate(structureCenter,boundary.sphere.center) + Vec3.negate(structureCenter, boundary.sphere.center) const m1: Mat4 = Mat4.identity() Mat4.setTranslation(m1, structureCenter) - structure = Structure.transform(structure,m1) + structure = Structure.transform(structure, m1) if (ingredient.offset){ - if (!Vec3.exactEquals(ingredient.offset,Vec3.zero())){ + if (!Vec3.exactEquals(ingredient.offset, Vec3.zero())){ const m: Mat4 = Mat4.identity(); Mat4.setTranslation(m, ingredient.offset) - structure = Structure.transform(structure,m); + structure = Structure.transform(structure, m); } } if (ingredient.principalAxis){ - if (!Vec3.exactEquals(ingredient.principalAxis,Vec3.unitZ)){ + if (!Vec3.exactEquals(ingredient.principalAxis, Vec3.unitZ)){ const q: Quat = Quat.identity(); - Quat.rotationTo(q,ingredient.principalAxis,Vec3.unitZ) + Quat.rotationTo(q, ingredient.principalAxis, Vec3.unitZ) const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q) - structure = Structure.transform(structure,m); + structure = Structure.transform(structure, m); } } } - return getAssembly(getResultTransforms(results,legacy), structure) + return getAssembly(getResultTransforms(results, legacy), structure) } } @@ -388,7 +391,7 @@ async function loadMembrane(name: string, plugin: PluginContext, runtime: Runtim } const url = `${params.baseUrl}/membranes/${name}.bcif` // - const file = (ingredientFiles)?ingredientFiles[fname]:null; + const file = (ingredientFiles) ? ingredientFiles[fname] : null; // can we check if url exist let membrane if (!file) { diff --git a/src/mol-plugin-ui/controls.tsx b/src/mol-plugin-ui/controls.tsx index 63409ca18b847924a66639e1fadcbf01d42cdff7..34661f0cf1c0749cdc7bc55c00f64e117493d6da 100644 --- a/src/mol-plugin-ui/controls.tsx +++ b/src/mol-plugin-ui/controls.tsx @@ -237,7 +237,7 @@ export class AnimationViewportControls extends PluginUIComponent<{}, { isEmpty: <div className='msp-semi-transparent-background' /> <IconButton icon={isAnimating || isPlaying ? 'stop' : 'tape'} transparent title={isAnimating ? 'Stop' : 'Select Animation'} onClick={isAnimating || isPlaying ? this.stop : this.toggleExpanded} - disabled={isAnimating|| isPlaying ? false : this.state.isBusy || this.state.isPlaying || this.state.isEmpty} /> + disabled={isAnimating || isPlaying ? false : this.state.isBusy || this.state.isPlaying || this.state.isEmpty} /> </div> {(this.state.isExpanded && !this.state.isBusy) && <div className='msp-animation-viewport-controls-select'> <AnimationControls onStart={this.toggleExpanded} /> diff --git a/src/mol-util/uuid.ts b/src/mol-util/uuid.ts index 541489a5f5f57d439bff87bdee88381c9eb5cc6e..e1dc052b87920f345d11ab9439d8a21605c0eedc 100644 --- a/src/mol-util/uuid.ts +++ b/src/mol-util/uuid.ts @@ -17,8 +17,8 @@ namespace UUID { export function create22(): UUID { let d = (+new Date()) + now(); for (let i = 0; i < 16; i++) { - chars[i] = String.fromCharCode((d + Math.random()*0xff)%0xff | 0); - d = Math.floor(d/0xff); + chars[i] = String.fromCharCode((d + Math.random() * 0xff) % 0xff | 0); + d = Math.floor(d / 0xff); } return _btoa(chars.join('')).replace(/\+/g, '-').replace(/\//g, '_').substr(0, 22) as UUID; } @@ -26,9 +26,9 @@ namespace UUID { export function createv4(): UUID { let d = (+new Date()) + now(); const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - const r = (d + Math.random()*16)%16 | 0; - d = Math.floor(d/16); - return (c==='x' ? r : (r&0x3|0x8)).toString(16); + const r = (d + Math.random() * 16) % 16 | 0; + d = Math.floor(d / 16); + return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); return uuid as any; }