SDRecord#

class biotite.structure.io.mol.SDRecord(header=None, ctab=None, metadata=None)[source]#

Bases: object

A record in a SD file.

Parameters:
headerHeader, optional

The header of the record. By default, an empty header is created.

ctabstr, optional

The connection table (atoms and bonds) in the record. By default, an empty structure is created.

metadataMetadata, Mapping or str, optional

The metadata of the record. Can be given as dictionary mapping Metadata.Key.name to the respective metadata value. By default, no metadata is appended to the record.

Examples

>>> atoms = residue("ALA")
>>> record = SDRecord(header=Header(mol_name="ALA", dimensions="3D"))
>>> record.set_structure(atoms)
>>> print(record.get_structure())
            0             N        -0.966    0.493    1.500
            0             C         0.257    0.418    0.692
            0             C        -0.094    0.017   -0.716
            0             O        -1.056   -0.682   -0.923
            0             C         1.204   -0.620    1.296
            0             O         0.661    0.439   -1.742
            0             H        -1.383   -0.425    1.482
            0             H        -0.676    0.661    2.452
            0             H         0.746    1.392    0.682
            0             H         1.459   -0.330    2.316
            0             H         0.715   -1.594    1.307
            0             H         2.113   -0.676    0.697
            0             H         0.435    0.182   -2.647
>>> # Add the record to an SD file
>>> file = SDFile()
>>> file["ALA"] = record
>>> print(file)
ALA
                    3D

 13 12  0     0  0  0  0  0  0  1 V2000
   -0.9660    0.4930    1.5000 N   0  0  0  0  0  0  0  0  0  0  0  0
    0.2570    0.4180    0.6920 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0940    0.0170   -0.7160 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.0560   -0.6820   -0.9230 O   0  0  0  0  0  0  0  0  0  0  0  0
    1.2040   -0.6200    1.2960 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.6610    0.4390   -1.7420 O   0  0  0  0  0  0  0  0  0  0  0  0
   -1.3830   -0.4250    1.4820 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6760    0.6610    2.4520 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.7460    1.3920    0.6820 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.4590   -0.3300    2.3160 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.7150   -1.5940    1.3070 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.1130   -0.6760    0.6970 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.4350    0.1820   -2.6470 H   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  1  7  1  0  0  0  0
  1  8  1  0  0  0  0
  2  3  1  0  0  0  0
  2  5  1  0  0  0  0
  2  9  1  0  0  0  0
  3  4  2  0  0  0  0
  3  6  1  0  0  0  0
  5 10  1  0  0  0  0
  5 11  1  0  0  0  0
  5 12  1  0  0  0  0
  6 13  1  0  0  0  0
M  END
$$$$
Attributes:
header, ctab, metadata

The same as the parameters.

static deserialize(text)#

Create an object by deserializing the given text content.

Parameters:
contentstr

The content to be deserialized.

get_structure()#

Parse the structural data in the SD record.

Returns:
arrayAtomArray

This AtomArray contains the optional charge annotation and has an associated BondList. All other annotation categories, except element are empty.

serialize()#

Convert this object into text content.

Returns:
contentstr

The serialized content.

set_structure(atoms, default_bond_type=BondType.ANY, version=None)#

Set the structural data in the SD record.

Parameters:
arrayAtomArray

The array to be saved into this file. Must have an associated BondList.

default_bond_typeBondType, optional

Bond type fallback for the Bond block, if a BondType has no CTAB counterpart. By default, each such bond is treated as BondType.ANY.

version{“V2000”, “V3000”}, optional

The version of the CTAB format. "V2000" uses the Atom and Bond block, while "V3000" uses the Properties block. By default, "V2000" is used, unless the number of atoms or bonds exceeds 999, in which case "V3000" is used.