wells-wood-research / elm-molecules / Biomolecules

This module provides tools to working with biomolecular structure.

Loading Structural Data

fetchStructuralData : (Result Error StructuralData -> msg) -> String -> Platform.Cmd.Cmd msg

Fetches structural data from the PDBe.

Uses the PDBe REST API to request the PDB format string for the protein of interest, using the 4 character PDB code to identify the structure.

Msg = RequestedStructuralData (Result Error StructuralData)

fetchStructuralData RequestedStructuralData "4pn9"

parsePdbString : String -> String -> Result Error StructuralData

Attempts to convert a string containing PDB format data into StructuralData.


type Error
    = PdbParseError String
    | HttpError Http.Error

Describes how a fetching StructuralData failed. The main errors arise either when requesting the data or when parsing the response.

Structure

To avoid a myriad of problems that often arise when working this structural data, structure is represented by a flat list of Atoms. These lists of Atoms can then be processed into groups relating to connectivity. Functions to do this are described in the next section.


type alias Atom =
{ serialNumber : Basics.Int
, name : String
, altLocation : Maybe String
, residueName : String
, chainId : Maybe String
, residueNumber : Basics.Int
, insertionCode : Maybe String
, position : { x : Basics.Float
, y : Basics.Float
, z : Basics.Float }
, occupancy : Maybe Basics.Float
, temperatureFactor : Maybe Basics.Float
, element : String
, charge : Maybe String
, stateNumber : Basics.Int 
}


type alias Residue =
{ atoms : List Atom
, stateNumber : Basics.Int
, chainId : Maybe String
, residueName : String
, residueNumber : Basics.Int 
}


type alias Chain =
{ atoms : List Atom
, stateNumber : Basics.Int
, chainId : Maybe String 
}


type alias State =
{ atoms : List Atom
, stateNumber : Basics.Int 
}


type alias StructuralData =
{ atoms : List Atom
, name : String 
}

List of Atoms representing the whole structure file.

Selections

chains : List Atom -> List Chain

Converts a list of atoms ordered by chain number into a list of chains.

residues : List Atom -> List Residue

Converts a list of atoms ordered by residue number into a list of residues.

Analysis

sequence : List Residue -> String

Creates a sequence string from a list of residues.

Uses single letter codes for amino acids if possible, otherwise it will use the three-letter code separated by dashes.

isProtein : Residue -> Basics.Bool

Codecs

See miniBill/elm-codec for more information about using codecs

structuralDataCodec : Codec StructuralData