Skip to content

Commit

Permalink
added random-coil-index coloring based on validation report xml file
Browse files Browse the repository at this point in the history
  • Loading branch information
arose committed Dec 13, 2018
1 parent 7ad92b9 commit cbe6bb0
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 50 deletions.
80 changes: 40 additions & 40 deletions ngl.sublime-project
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"folders":
[
{
"path": "."
}
],
"settings":
{
"tab_size": 4,
"translate_tabs_to_spaces": false,
"trim_trailing_white_space_on_save": true
},
"build_systems":
[
{
"name": "Lint",
"shell_cmd": "npm run-script lint",
"working_dir": "${project_path}",
},
{
"name": "Test",
"shell_cmd": "npm test",
"working_dir": "${project_path}",
},
{
"name": "Build",
"shell_cmd": "npm run-script build",
"working_dir": "${project_path}",
},
{
"name": "Watch",
"shell_cmd": "npm run-script watch",
"working_dir": "${project_path}",
},
{
"name": "Rollup",
"shell_cmd": "rollup -c",
"working_dir": "${project_path}",
}
]
"build_systems":
[
{
"name": "Lint",
"shell_cmd": "npm run-script lint",
"working_dir": "${project_path}"
},
{
"name": "Test",
"shell_cmd": "npm test",
"working_dir": "${project_path}"
},
{
"name": "Build",
"shell_cmd": "npm run-script build",
"working_dir": "${project_path}"
},
{
"name": "Watch",
"shell_cmd": "npm run-script watch",
"working_dir": "${project_path}"
},
{
"name": "Rollup",
"shell_cmd": "rollup -c",
"working_dir": "${project_path}"
}
],
"folders":
[
{
"path": "."
}
],
"settings":
{
"tab_size": 4,
"translate_tabs_to_spaces": false,
"trim_trailing_white_space_on_save": true
}
}
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/color/randomcoilindex-colormaker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @file Randomcoilindex Colormaker
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @private
*/

import { ColormakerRegistry } from '../globals'
import Colormaker, { StuctureColormakerParams, ColormakerScale } from './colormaker'
import AtomProxy from '../proxy/atom-proxy'

/**
* Color by random coil index
*/
class RandomcoilindexColormaker extends Colormaker {
rciScale: ColormakerScale
rciDict: { [k: string]: number|undefined } = {}

constructor (params: StuctureColormakerParams) {
super(params)

if (!params.scale) {
this.parameters.scale = 'RdYlBu'
}

this.rciScale = this.getScale({ domain: [ 1, 0 ] })

const val = params.structure.validation
if (val) this.rciDict = val.rciDict

}

atomColor (atom: AtomProxy) {
let sele = `[${atom.resname}]${atom.resno}`
if (atom.chainname) sele += ':' + atom.chainname

const rci = this.rciDict[ sele ]
return rci !== undefined ? this.rciScale(rci) : 0x909090
}
}

ColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker as any)

export default RandomcoilindexColormaker
1 change: 1 addition & 0 deletions src/ngl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import './color/moleculetype-colormaker'
import './color/occupancy-colormaker'
import './color/partialcharge-colormaker'
import './color/random-colormaker'
import './color/randomcoilindex-colormaker'
import './color/residueindex-colormaker'
import './color/resname-colormaker'
import './color/sstruc-colormaker'
Expand Down
49 changes: 44 additions & 5 deletions src/structure/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,27 @@ function getNamedItem(a: NamedNodeMap, name: string) {
}

function getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {
const icode = getNamedItem(a, 'icode')
const chain = getNamedItem(a, 'chain')
const icode = getNamedItem(a, 'icode').trim()
const chain = getNamedItem(a, 'chain').trim()
const altcode = getNamedItem(a, 'altcode')
let sele = getNamedItem(a, 'resnum')
if (icode.trim()) sele += '^' + icode
if (chain.trim()) sele += ':' + chain
if (icode) sele += '^' + icode
if (chain) sele += ':' + chain
if (atomname) sele += '.' + atomname
if (useAltcode && altcode.trim()) sele += '%' + altcode
sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)
return sele
}

function getResSele (a: NamedNodeMap) {
const chain = getNamedItem(a, 'chain').trim()
const rescode = getNamedItem(a, 'rescode')
const resnum = getNamedItem(a, 'resnum')
let sele = `[${rescode}]${resnum}`
if (chain) sele += `:${chain}`
return sele
}

function setBitDict (dict: { [k: string]: number }, key: string, bit: number) {
if (dict[ key ] === undefined) {
dict[ key ] = bit
Expand Down Expand Up @@ -102,14 +111,30 @@ function getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g
class Validation {
rsrzDict: { [k: string]: number } = {}
rsccDict: { [k: string]: number } = {}
/**
* Random Coil Index (RCI) - evaluates the proximity of residue structural
* and dynamic properties to the properties of flexible random coil regions
* from NMR chemical shifts.
*
* Mark V. Berjanskii and David S. Wishart (2005)
* A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts
* J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971
* http://pubs.acs.org/doi/abs/10.1021/ja054842f
*
* Mark V. Berjanskii and David S. Wishart (2008)
* Application of the random coil index to studying protein flexibility.
* J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.
* http://www.springerlink.com/content/2966482w10306126/
*/
rciDict: { [k: string]: number } = {}
clashDict: { [k: string]: { [k: string]: string } } = {}
clashArray: { [k: string]: string }[] = []
geoDict: { [k: string]: number } = {}
geoAtomDict: { [k: string]: { [k: string]: number } } = {}
atomDict: { [k: string]: boolean|number } = {}
clashSele = 'NONE'

constructor (readonly name: string, readonlypath: string) {}
constructor (readonly name: string, readonly path: string) {}

get type () { return 'validation' }

Expand All @@ -118,12 +143,26 @@ class Validation {

const rsrzDict = this.rsrzDict
const rsccDict = this.rsccDict
const rciDict = this.rciDict
const clashDict = this.clashDict
const clashArray = this.clashArray
const geoDict = this.geoDict
const geoAtomDict = this.geoAtomDict
const atomDict = this.atomDict

const entries = xml.getElementsByTagName('Entry')
if (entries.length === 1) {
const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')
if (chemicalShiftLists.length === 1) {
const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')
for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {
const rcia = randomCoilIndices[ j ].attributes
const sele = getResSele(rcia)
rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))
}
}
}

const groups = xml.getElementsByTagName('ModelledSubgroup')

const _clashDict: { [k: string]: { [k: string]: string } } = {}
Expand Down

0 comments on commit cbe6bb0

Please sign in to comment.