chemjson

package
Version: v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2021 License: LGPL-2.1 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeOptions

func DecodeOptions(stdin *bufio.Reader) (*Options, *Error)

DecodeOptions Decodes or unmarshals json options into an Options structure

Types

type Atom

type Atom struct {
	A      *chem.Atom
	Coords []float64
	Bfac   float64
}

type Coords

type Coords struct {
	Coords []float64
}

type Error

type Error struct {
	IsError       bool //If this is false (no error) all the other fields will be at their zero-values.
	InOptions     bool //If error, was it in parsing the options?
	InSelections  bool //Was it in parsing selections?
	InProcess     bool
	InPostProcess bool   //was it in preparing the output?
	Selection     string //Which selection?
	State         int    //Which state of it?
	Atom          int
	Function      string //which go function gave the error
	Message       string //the error itself
	// contains filtered or unexported fields
}

An easily JSON-serializable error type,

func DecodeCoords

func DecodeCoords(stream *bufio.Reader, atomnumber int) (*v3.Matrix, *Error)

Decodecoords decodes streams from a bufio.Reader containing 3*atomnumber JSON floats into a v3.Matrix with atomnumber rows.

func DecodeMolecule

func DecodeMolecule(stream *bufio.Reader, atomnumber, frames int) (*chem.Topology, []*v3.Matrix, *Error)

DecodeMolecule Decodes a JSON molecule into a gochem molecule. Can handle several frames (all of which need to have the same amount of atoms). It does not collect the b-factors.

func EncodeAtoms

func EncodeAtoms(mol chem.Atomer, enc *json.Encoder) *Error

func EncodeCoords

func EncodeCoords(coords *v3.Matrix, enc *json.Encoder) *Error

func NewError

func NewError(where, function string, err error) *Error

Takes an error and some additional info to create a json-marshal-ble error

func SendMolecule

func SendMolecule(mol chem.Atomer, coordset, bfactors []*v3.Matrix, ss [][]string, out io.Writer) *Error

Takes a chem.Atomer, coordinates, bfactos and secondary strucuctures, encodes them and writes them to the given io.writer

func (Error) Decorate

func (err Error) Decorate(dec string) []string

Decorate will add the dec string to the decoration slice of strings of the error, and return the resulting slice.

func (*Error) Error

func (J *Error) Error() string

implements the error interface

func (*Error) Marshal

func (J *Error) Marshal() []byte

Serializes the error. Panics on failure.

type Info

type Info struct {
	Molecules         int
	Bfactors          bool
	SS                bool
	FramesPerMolecule []int
	AtomsPerMolecule  []int
	FloatInfo         [][]float64
	StringInfo        [][]string
	IntInfo           [][]int
	BoolInfo          [][]bool
	Energies          []float64
}

Information to be passed back to the calling program.

func (*Info) Send

func (J *Info) Send(out io.Writer) *Error

Send Marshals the info and writes to out, returns an error or nil

type Options

type Options struct {
	SelNames      []string
	AtomsPerSel   []int //Knowing in advance makes memory allocation more efficient
	StatesPerSel  []int //How many snapshots a traj has?
	StringOptions [][]string
	IntOptions    [][]int
	BoolOptions   [][]bool
	FloatOptions  [][]float64
}

Options passed from the calling external program

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL