Skip to main content

protein_core/structure/
secondary_structure.rs

1use super::serial::ResidueSerial;
2use super::AtomName;
3use serde::Serialize;
4
5/// # Overview
6///
7/// HELIX records are used to identify the position of helices in the molecule. Helices are named, numbered, and classified by type. The residues where the helix begins and ends are noted, as well as the total length.
8///
9/// # Record Format
10///
11///|COLUMNS  |      DATA  TYPE    | FIELD        | DEFINITION
12///|---------|--------------------|--------------|----------------------------------------
13///| 1 -  6  |      Record name   | "HELIX "     |                                         
14///| 8 - 10  |      Integer       | serNum       | Serial number of the helix. This starts
15///|         |                    |              | at 1  and increases incrementally.
16///|12 - 14  |      LString(3)    | helixID      | Helix  identifier. In addition to a serial
17///|         |                    |              | number, each helix is given an
18///|         |                    |              | alphanumeric character helix identifier.
19///|16 - 18  |      Residue name  | initResName  | Name of the initial residue.
20///|20       |      Character     | initChainID  | Chain identifier for the chain containing
21///|         |                    |              | this  helix.
22///|22 - 25  |      Integer       | initSeqNum   | Sequence number of the initial residue.
23///|26       |      AChar         | initICode    | Insertion code of the initial residue.
24///|28 - 30  |      Residue  name | endResName   | Name of the terminal residue of the helix.
25///|32       |      Character     | endChainID   | Chain identifier for the chain containing
26///|         |                    |              | this  helix.
27///|34 - 37  |      Integer       | endSeqNum    | Sequence number of the terminal residue.
28///|38       |      AChar         | endICode     | Insertion code of the terminal residue.
29///|39 - 40  |      Integer       | helixClass   | Helix class (see below).
30///|41 - 70  |      String        | comment      | Comment about this helix.
31///|72 - 76  |      Integer       | length       | Length of this helix.
32///
33/// # Details
34///
35/// Additional HELIX records with different serial numbers and identifiers occur if more than one helix is present.
36/// The initial residue of the helix is the N-terminal residue.
37/// Helices are classified as follows:
38///
39/// |                                |     CLASS NUMBER             |           
40/// |TYPE OF  HELIX                  |   (COLUMNS 39 - 40)          |              
41/// |--------------------------------|------------------------------|
42/// |Right-handed alpha (default)    |            1                 |       
43/// |Right-handed omega              |            2                 |       
44/// |Right-handed pi                 |            3                 |       
45/// |Right-handed gamma              |            4                 |       
46/// |Right-handed 3 - 10             |            5                 |       
47/// |Left-handed alpha               |            6                 |       
48/// |Left-handed omega               |            7                 |       
49/// |Left-handed gamma               |            8                 |       
50/// |2 - 7 ribbon/helix              |            9                 |       
51/// |Polyproline                     |           10                 |       
52#[derive(Debug, Clone, Serialize)]
53pub struct Helix {
54    // pub serial: SecondaryStructureSerial, // * implied
55    pub id: String,
56    pub class: HelixClass,
57    pub start: (char, ResidueSerial),
58    //start_res: AminoAcid,
59    pub end: (char, ResidueSerial),
60    //end_res: AminoAcid,
61    pub comment: String,
62    // length: usize, // * implied
63}
64
65#[derive(Debug, Clone, Serialize, Copy)]
66pub enum HelixClass {
67    RightHandedAlpha,
68    RightHandedOmega,
69    RightHandedPi,
70    RightHandedGamma,
71    RightHanded310,
72    LeftHandedAlpha,
73    LeftHandedOmega,
74    LeftHandedGamma,
75    TwoSevenRibbonHelix,
76    Polyproline,
77    Unknown,
78}
79
80impl Default for HelixClass {
81    fn default() -> Self {
82        Self::Unknown
83    }
84}
85
86/// # Fields
87///
88///
89/// # PDB Specification
90///
91/// ## Overview
92///
93/// SHEET records are used to identify the position of sheets in the molecule. Sheets are both named and numbered. The residues where the sheet begins and ends are noted.
94///
95/// ## Record Format
96///
97/// | COLUMNS | DATA  TYPE   | FIELD       | DEFINITION                                        |
98/// | ------- | ------------ | ----------- | ------------------------------------------------- |
99/// | 1 -  6  | Record name  | "SHEET "    |                                                   |
100/// | 8 - 10  | Integer      | strand      | Strand  number which starts at 1 for each         |
101/// |         |              |             | strand within a sheet and increases by one.       |
102/// | 12 - 14 | LString(3)   | sheetID     | Sheet  identifier.                                |
103/// | 15 - 16 | Integer      | numStrands  | Number  of strands in sheet.                      |
104/// | 18 - 20 | Residue name | initResName | Residue  name of initial residue.                 |
105/// | 22      | Character    | initChainID | Chain identifier of initial residue               |
106/// |         |              |             | in strand.                                        |
107/// | 23 - 26 | Integer      | initSeqNum  | Sequence number of initial residue                |
108/// |         |              |             | in strand.                                        |
109/// | 27      | AChar        | initICode   | Insertion code of initial residue                 |
110/// |         |              |             | in  strand.                                       |
111/// | 29 - 31 | Residue name | endResName  | Residue name of terminal residue.                 |
112/// | 33      | Character    | endChainID  | Chain identifier of terminal residue.             |
113/// | 34 - 37 | Integer      | endSeqNum   | Sequence number of terminal residue.              |
114/// | 38      | AChar        | endICode    | Insertion code of terminal residue.               |
115/// | 39 - 40 | Integer      | sense       | Sense of strand with respect to previous          |
116/// |         |              |             | strand in the sheet. 0 if first strand,           |
117/// |         |              |             | 1 if  parallel,and -1 if anti-parallel.           |
118/// | 42 - 45 | Atom         | curAtom     | Registration.  Atom name in current strand.       |
119/// | 46 - 48 | Residue name | curResName  | Registration.  Residue name in current strand     |
120/// | 50      | Character    | curChainId  | Registration. Chain identifier in                 |
121/// |         |              |             | current strand.                                   |
122/// | 51 - 54 | Integer      | curResSeq   | Registration.  Residue sequence number            |
123/// |         |              |             | in current strand.                                |
124/// | 55      | AChar        | curICode    | Registration. Insertion code in                   |
125/// |         |              |             | current strand.                                   |
126/// | 57 - 60 | Atom         | prevAtom    | Registration.  Atom name in previous strand.      |
127/// | 61 - 63 | Residue name | prevResName | Registration.  Residue name in                    |
128/// |         |              |             | previous strand.                                  |
129/// | 65      | Character    | prevChainId | Registration.  Chain identifier in                |
130/// |         |              |             | previous  strand.                                 |
131/// | 66 - 69 | Integer      | prevResSeq  | Registration. Residue sequence number             |
132/// |         |              |             | in previous strand.                               |
133/// | 70      | AChar        | prevICode   | Registration.  Insertion code in previous strand. |
134///
135/// ## Details
136///
137/// - The initial residue for a strand is its N-terminus. Strand registration information is provided in columns 39 - 70. Strands are listed starting with one edge of the sheet and continuing to the spatially adjacent strand.
138/// - The sense in columns 39 - 40 indicates whether strand n is parallel (sense = 1) or anti-parallel (sense = -1) to strand n-1. Sense is equal to zero (0) for the first strand of a sheet.
139/// - The registration (columns 42 - 70) of strand n to strand n-1 may be specified by one hydrogen bond between each such pair of strands. This is done by providing the hydrogen bonding between the current and previous strands. No register information should be provided for the first strand.
140/// - Split strands, or strands with two or more runs of residues from discontinuous parts of the amino acid sequence, are explicitly listed. Detail description can be included in the REMARK 700 .
141#[derive(Serialize, Debug, Default, Clone)]
142pub struct Sheet {
143    pub id: String,
144    pub strands: Vec<Strand>,
145    pub registration: Vec<Registration>,
146}
147
148#[derive(Serialize, Debug, Clone)]
149pub struct Strand {
150    //pub serial: SsSerial, // * implied
151    //pub nstrand: u8, // * implied
152    pub start: (char, ResidueSerial),
153    pub end: (char, ResidueSerial),
154    //start_res: AminoAcid,
155    //end_res: AminoAcid,
156    pub sense: Sense,
157}
158
159/// # Fields
160///
161/// `cur` and `prev` are tuples containing 1. the element (N or O) 2. the chain identifier and 3. sequence number
162#[derive(Serialize, Debug, Clone)]
163pub struct Registration {
164    pub curr: (AtomName, char, ResidueSerial),
165    pub prev: (AtomName, char, ResidueSerial),
166}
167
168#[derive(Serialize, Debug, Clone, Copy)]
169pub enum Sense {
170    Parallel,
171    Antiparallel,
172    Unknown,
173}