chemjson

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 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
}

A ready-to-serialize container for an atom.

type Coords

type Coords struct {
	Coords []float64
}

A ready-to-serialize container for coordinates

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

Encodes a goChem Atomer into a JSON

func EncodeCoords

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

Encodes a set of coordinates into JSON

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

Error 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL