pdbFile(API)

From EosPedia
Jump to: navigation, search

DataManip/pdbFile is API to treat PDB file.

constant

Syntax for PDB file

String length definition

#define PDB_FILE_RECORD_FULL_LENGTH (80)
#define PDB_FILE_RECORD_START       (0)
#define PDB_FILE_RECORD_LENGTH      (6)
#define PDB_FILE_ATOM_NUMBER_START  (6)
#define PDB_FILE_ATOM_NUMBER_LENGTH (5)
#define PDB_FILE_ATOM_NAME_START    (12)
#define PDB_FILE_ATOM_NAME_LENGTH   (4)
#define PDB_FILE_LOCATION_START     (16)
#define PDB_FILE_LOCATION_LENGTH    (1)
#define PDB_FILE_RESIDUE_START      (17)
#define PDB_FILE_RESIDUE_LENGTH     (3)
#define PDB_FILE_CHAIN_IDENT_START  (21)
#define PDB_FILE_CHAIN_IDENT_LENGTH (1)
#define PDB_FILE_RESNUM_START       (22)
#define PDB_FILE_RESNUM_LENGTH      (4)
#define PDB_FILE_INSERTION_START    (26)
#define PDB_FILE_INSERTION_LENGTH   (1)
#define PDB_FILE_X_START            (30)
#define PDB_FILE_X_LENGTH           (8)
#define PDB_FILE_Y_START            (38)
#define PDB_FILE_Y_LENGTH           (8)
#define PDB_FILE_Z_START            (46)
#define PDB_FILE_Z_LENGTH           (8)
#define PDB_FILE_OCCUPANCY_START    (54)
#define PDB_FILE_OCCUPANCY_LENGTH   (6)
#define PDB_FILE_TEMPERATURE_START  (60)
#define PDB_FILE_TEMPERATURE_LENGTH (6)
#define PDB_FILE_FOOT_START         (67)
#define PDB_FILE_FOOT_LENGTH        (3)
#define PDB_FILE_FOOTNOTE_START     (70)
#define PDB_FILE_FOOTNOTE_LENGTH    (10)
#define MAX_RESIDUE_NUMBER          (20)
#define RESIDUE_ONECHAR_MODE        (1)
#define RESIDUE_THREECHAR_MODE      (3)

String definition

#define pdbRecordAtom       ("ATOM  ")
#define pdbRecordHeteroAtom ("HETATM")
#define pdbRecordHelix      ("HELIX ")
#define pdbRecordSheet      ("SHEET ")
#define pdbRecordTurn       ("TURN  ")
#define pdbRecordEnd        ("END   ")

Residue Name

residueName3: 3 characters, residueName1: 1 character

typedef struct residueName {
  char residueName3[4];
  char residueName1[2];
} residueName;

Define the struct in header file, and define residue name in /pdbFile/src/pdbGet.c.

static residueName residue[MAX_RESIDUE_NUMBER] = { 
"ALA","A", "VAL","V", "PHE","F", "PRO","P",
"MET","M", "ILE","I", "LEU","L", "ASP","D",
"GLU","E", "LYS","K", "ARG","R", "SER","S",
"THR","T", "TYR","Y", "HIS","H", "CYS","C",
"ASN","N", "GLN","Q", "TRP","W", "GLY","G"
};
Element No. residueName3 residueName1
0 ALA A
1 VAL V
2 PHE F
3 PRO P
4 MET M
5 ILE I
6 LEU L
7 ASP D
8 GLU E
9 LYS K
10 ARG R
11 SER S
12 THR T
13 TYR Y
14 HIS H
15 CYS C
16 ASN N
17 GLN Q
18 TRP W
19 GLY G


Secondary Structure

Secondary Structure Mode

typedef enum pdbFileSecondaryStructureMode {
	pdbFileSecondaryStructureModeNo    = 0,
	pdbFileSecondaryStructureModeHelix = 1,
	pdbFileSecondaryStructureModeSheet = 2,
	pdbFileSecondaryStructureModeTurn  = 3
} pdbFileSecondaryStructureMode;

Helix Structure

typedef enum pdbSecondaryStructureHelixClass {
	HelixClassRightHandedAlpha = 1,
	HelixClassRightHandedOmega = 2,
	HelixClassRightHandedPi    = 3,
	HelixClassRightHandedGammda= 4,
	HelixClassRightHanded310   = 5,
	HelixClassLeftHandedAlpha  = 6,
	HelixClassLeftHandedOmega  = 7,
	HelixClassLeftHandedGammda = 9,
	HelixClassPolyProline      = 10,
} pdbSecondaryStructureHelixClass;

struct

Management Data

This is struct to manage PDB data and Secondary Structure data.

typedef struct pdbFile {
  pdbRecord* top;
  pdbRecord* PDB;
  pdbFileParaTypeInteger nAtom;
  pdbFileSecondaryStructure second;
} pdbFile;
Member Description
top Top PDB data(Pointer)
PDB Current PDB data(Pointer)
nAtom Number of PDB data
second Secondary Structure data


Management Secondary Structure data

typedef struct pdbFileSecondaryStructure {
	int nSecondaryStructure;
	pdbFileSecondaryStructureRecord* top;
	pdbFileSecondaryStructureRecord* SecondaryStructure; 
} pdbFileSecondaryStructure;
Member Description
nSecondaryStructure Number of Secondary Structure data
top Top Secondary Structure data(Pointer)
SecondaryStructure Current Secondary Structure data(Pointer)


PDB data

This is struct to store PDB data. Manage by list, and correspond one line PDB file data.

typedef struct pdbRecord pdbRecord;

struct pdbRecord {
  pdbFileParaTypeCharacter FullRecord[PDB_FILE_RECORD_FULL_LENGTH+1];

  pdbFileParaTypeCharacter Record[PDB_FILE_RECORD_LENGTH+1];

/* ATOM and HETATM Record */
  pdbFileParaTypeInteger   AtomSerialNumber;
  pdbFileParaTypeCharacter AtomName[PDB_FILE_ATOM_NAME_LENGTH+1];
  pdbFileParaTypeCharacter LocationIndicator;
  pdbFileParaTypeCharacter ResidueName[PDB_FILE_RESIDUE_LENGTH+1];
  pdbFileParaTypeCharacter ChainIdentifier;
  pdbFileParaTypeInteger   ResidueSequenceNumber;
  pdbFileParaTypeCharacter InsertionCode;
  pdbCoord                 Coord;
  pdbFileParaTypeReal      Occupancy;
  pdbFileParaTypeReal      TemperatureFactor;
  pdbFileParaTypeInteger   FootnoteNumber;
  pdbFileParaTypeCharacter Footnote[PDB_FILE_FOOTNOTE_LENGTH+1];

  pdbRecord*               prev;
  pdbRecord*               next;
};
Member Description
FullRecord One line PDB data
Record One line PDB data as Atom Information
AtomSerialNumber
AtomName Atom Name
LocationIndicator
ResidueName Residue Name
ChainIdentifier Chain ID
ResidueSequenceNumber Residue Sequence Number
InsertionCode
Coord Coordinates of Atom
Occupancy Occupancy
TemperatureFactor Temperature Factor
FootnoteNumber
Footnote
prev Previous data
next Next data


typedef char  pdbFileParaTypeCharacter;
typedef long  pdbFileParaTypeInteger;
typedef float pdbFileParaTypeReal;

Coordinates of PDB data

typedef struct pdbCoord {
  pdbFileParaTypeReal x;
  pdbFileParaTypeReal y;
  pdbFileParaTypeReal z;
} pdbCoord;

Secondary Structure

This is struct to store Secondary Structure data.Manage by list, and correspond one line Secondary Structure.

typedef struct pdbFileSecondaryStructureRecord pdbFileSecondaryStructureRecord; 
struct pdbFileSecondaryStructureRecord {
	pdbFileSecondaryStructureMode mode;
	pdbSecondaryStructureHelix*   helix;
	pdbSecondaryStructureSheet*   sheet;
	pdbSecondaryStructureTurn*    turn;
	pdbSecondaryStructureNo*      no;

	pdbFileSecondaryStructureRecord* prev;
	pdbFileSecondaryStructureRecord* next;
};
Member Description
mode Secondary Structure Mode
helix Helix Structure data
sheet Sheet Structure data
turn Turn Structure data
no Non Secondary Structure data
prev Previous data
next Next data


Helix Structure

typedef struct pdbSecondaryStructureHelix {
	int  serNum;     	/* Serial Number */
	char* helixID;   	/* HelixID : Three alpahnumeric characters */
/* informtion for the initial residue */
	char* initResName;/* Name of the initial residue : Three alpahnumeric characters */ 
	char initChainID;  	/* Chain identifier */ 
	int  initSeqNum;    /* Sequence number of the initial residue */
	char initICode; 
/* informtion for the terminal residue */
	char* endResName;/* Name of the initial residue : Three alpahnumeric characters */ 
	char endChainID;  	/* Chain identifier */ 
	int  endSeqNum;    /* Sequence number of the initial residue */
	char endICode; 

	pdbSecondaryStructureHelixClass helixClass;
	char* comment; 
	int  length;
} pdbSecondaryStructureHelix;

Sheet Structure

typedef struct pdbSecondaryStructureSheet {
	int  strand; 		/* Strand number which starts 1 for eache strand wihtin a sheet and increases by one */  
	char* sheetID;    /* Sheet ID */			
	int  numStrands;    /* Number of strands in sheet */

/* initial residue */
	char* initResName;/* Name of the initial residue : Three alpahnumeric characters */ 
	char initChainID;  	/* Chain identifier */ 
	int  initSeqNum;    /* Sequence number of the initial residue */
	char initICode; 

/* informtion for the terminal residue */
	char* endResName;/* Name of the initial residue : Three alpahnumeric characters */ 
	char endChainID;  	/* Chain identifier */ 
	int  endSeqNum;    /* Sequence number of the initial residue */
	char endICode; 

	int sense;  /* 0: first strand, 1: parallel, -1: anti-paralle */ 

	char* curAtom; /* Registration. Atom name in current strand */
	char* curResName; /* Registration. Residue name in current strand */
	char curChainID; /* Registration. Chain ID in current strand */
	int  curResSeq;  /* Registration. Res sequence in current strand */
	char curICode;  /* Registration. Insertion code in current strand */

	char* prevAtom; /* Registration. Atom name in current strand */
	char* prevResName; /* Registration. Residue name in current strand */
	char prevChainID; /* Registration. Chain ID in current strand */
	int prevResSeq;  /* Registration. Res sequence in current strand */
	char prevICode;  /* Registration. Insertion code in current strand */
}pdbSecondaryStructureSheet;

Turn Structure

typedef struct pdbSecondaryStructureTurn {
	int  serNum;     	/* Serial Number */
	char* turnID;   	/* Turn ID : Three alpahnumeric characters */
/* informtion for the initial residue */
	char* initResName;/* Name of the initial residue : Three alpahnumeric characters */ 
	char initChainID;  	/* Chain identifier */ 
	int  initSeqNum;    /* Sequence number of the initial residue */
	char initICode; 
/* informtion for the terminal residue */
	char* endResName;/* Name of the initial residue : Three alpahnumeric characters */ 
	char endChainID;  	/* Chain identifier */ 
	int  endSeqNum;    /* Sequence number of the initial residue */
	char endICode; 

	char* comment; 
}pdbSecondaryStructureTurn;

Non Secondary Structure

typedef struct pdbSecondaryStructureNo {
	int   serNum;     	/* Serial Number */
	char* noID;   	    /* Turn ID : Three alpahnumeric characters */
/* informtion for the initial residue */
	char* initResName;/* Name of the initial residue : Three alpahnumeric characters */ 
	char initChainID;  	/* Chain identifier */ 
	int  initSeqNum;    /* Sequence number of the initial residue */
	char initICode; 
/* informtion for the terminal residue */
	char* endResName;/* Name of the initial residue : Three alpahnumeric characters */ 
	char endChainID;  	/* Chain identifier */ 
	int  endSeqNum;    /* Sequence number of the initial residue */
	char endICode; 

	char* comment; 
}pdbSecondaryStructureNo;

API

File Management

Read

Read data in file fpt, and store to manage data pdb.

extern void pdbFileRead(FILE* fpt, pdbFile* pdb);

Write

Write manage data pdb to file fpt as PDB. (Repeat to use pdbFileRecordPrint)

extern void pdbFileWrite(FILE* fpt, pdbFile* pdb);

Write manage data pdb to file fpt as tsv. (Repeat to use pdbFileRecordTablePrint)

extern void pdbFileTableWrite(FILE* fpt, pdbFile* pdb); 

Write coordinates list in manage data pdb to file fpt.

extern void pdbFileWriteCoord(FILE* fpt, pdbFile* pdb);

Treat PDB data

New Create

Create new data to pdb->PDB.
Create new data allocating memory. Then set it to top data. In addition, set NULL to the previous and the next data.

extern pdbRecord* pdbFileNew(pdbFile* pdb);

Append

Create new data to next of pdb->PDB.
Create new data allocating memory. Then set it to current data, original data to previous data, and original next data to next data.

extern pdbRecord* pdbFileAppend(pdbFile* pdb);

Release

Release all of PDB data in pdb.

extern pdbRecord* pdbFileFree(pdbFile* pdb);

Write

Write pdb->PDB to file fpt as PDB.

extern pdbRecord* pdbFileRecordPrint(FILE* fpt, pdbFile* pdb);

Write pdb->PDB to file fpt as tsv.

extern pdbRecord* pdbFileRecordTablePrint(FILE* fpt, pdbFile* pdb);

Pointer move

Move to top data.

extern pdbRecord* pdbFileTop(pdbFile* pdb);

Return pointer of top data to pdb->top.

extern pdbRecord* pdbFileTopPointer(pdbFile* pdb);

Move to next data.(If don't correspond, return NULL.)

extern pdbRecord* pdbFileNext(pdbFile* pdb);

Move to next Atom data.(If don't correspond, return NULL.)

extern pdbRecord* pdbFileNextAtom(pdbFile* pdb);

Move to next alpha carbon data.(If don't correspond, return NULL.)

extern pdbRecord* pdbFileNextCA(pdbFile* pdb);

Move to previous data.(If don't correspond, return NULL.)

extern pdbRecord* pdbFilePrev(pdbFile* pdb);

Move to previous Atom data.(If don't correspond, return NULL.)

extern pdbRecord* pdbFilePrevAtom(pdbFile* pdb);

Move to previous alpha carbon data.(If don't correspond, return NULL.)

extern pdbRecord* pdbFilePrevCA(pdbFile* pdb);

Move to end data.

extern long pdbFileGoToEnd(pdbFile* pdb);

Check Data

If end data, return 1. Otherwise, return 0.

extern long pdbFileEnd(pdbFile* pdb);

If pdb->PDB->Record is end character(END), return 1. Otherwise, return 0.

extern long pdbFileIsEndLine(pdbFile* pdb);

If pdb->PDB->Record is Atom, return 1. Otherwise, return 0.

extern long pdbFileIsAtom(pdbFile* pdb);

If pdb->PDB->AtomName is alpha carbon( CA ), return 1. Otherwise, return 0.

extern long pdbFileIsCA(pdbFile* pdb);

Return Z value from pdb->PDB->AtomName. If don't correspond, return 6 as carbon.

extern pdbFileParaTypeInteger pdbZValueGet(pdbFile* pdb);

If residue name of pdb->PDB is "D" or "E", return 1. Otherwise, return 0.

extern long pdbFileIsNegative(pdbFile* pdb);

If residue name of pdb->PDB is "K" or "R", return 1. Otherwise, return 0.

extern long pdbFileIsPositive(pdbFile* pdb);

If residue name of pdb->PDB is "K", "R", "D", or "E", return 1. Otherwise, return 0.

extern long pdbFileIsCharge(pdbFile* pdb);

If records have same ChainID and their sequence number difference is 1, return 1. Otherwise, return 0.

extern long pdbRecordIsNearby(pdbRecord record1,pdbRecord record2);

Set data

Set (x, y, z) to pdb->PDB->Coord.

extern long pdbFileCoordSet(pdbFile* pdb, pdbFileParaTypeReal x, pdbFileParaTypeReal y, pdbFileParaTypeReal z);

Set temp to pdb->PDB->TemperatureFactor.

extern void pdbFileTemperatureFactorSet(pdbFile* pdb, double temp);

Set c to pdb->PDB->ChainIdentifier.

extern void pdbFileChainIdentifierSet(pdbFile* pdb, unsigned char c);

Set c to all Chain ID in pdb.

extern void pdbFileChainIdentifierSetAll(pdbFile* pdb, unsigned char c);

Set temp to pdb->PDB->Occupancy.

extern void pdbFileOccupancySet(pdbFile* pdb, double temp);

Get data

Output pdb->PDB->Coord to (x, y, z).

extern long pdbFileCoordGet(pdbFile* pdb, pdbFileParaTypeReal* x, pdbFileParaTypeReal* y, pdbFileParaTypeReal* z);

Return pdb->PDB->ResidueSequenceNumber.

extern long pdbFileResidueSequenceNumberGet(pdbFile* pdb);

Return residue name. (If mode=RESIDUE_THREECHAR_MODE, 3 characters. Otherwise, 1 character)

extern char* pdbFileResidueNameGet(pdbFile* pdb,int mode);

Return pdb->PDB->TemperatureFactor.

extern pdbFileParaTypeReal pdbFileTemperatureFactorGet(pdbFile* pdb);

Return pdb->PDB->ChainIdentifier.

extern unsigned char pdbFileChainIdentifierGet(pdbFile* pdb);

Return pdb->PDB->Occupancy.

extern pdbFileParaTypeReal pdbFileOccupancyGet(pdbFile* pdb);

Increase

Increase pdb->PDB->ResidueSequenceNumber by 1..

extern void pdbFileResidueSequenceNumberIncrement(pdbFile* pdb, int n);

Increase all Residue Sequence Number in pdb by 1.

extern void pdbFileResidueSequenceNumberIncrementAll(pdbFile* pdb, int n);

Copy

Copy src->PDB to dst->PDB.
Then, keep the relation to previous and next data, and return dst->PDB.

extern pdbRecord* pdbFileOneRecordCopy(pdbFile* dst, pdbFile* src);

Copy all PDB data in src to dst with overwrite.
Copy calling pdbFileNew for dst. So, you must release dst by pdbFileFree , before using it.

extern void pdbFileCopyAll(pdbFile* dst, pdbFile* src);

Append all PDB data in src, to next of dst->PDB.

extern void pdbFileAppendAll(pdbFile* dst, pdbFile* src);

If src->PDB is alpha carbon, copy it to dst->PDB.
Then, keep the relation to previous and next data, and if the copy is succeed, return dst->PDB. Otherwise, return NULL.

extern pdbRecord* pdbFileCAOnlyCopy(pdbFile* pdb, pdbFile* src);

Copy all alpha carbon data in src to dst with overwrite.
Copy calling pdbFileNew for dst. So, you must release dst by pdbFileFree , before using it.

extern void pdbFileCAOnlyCopyAll(pdbFile* pdb, pdbFile* src);

Copy src to dst as one protein data.
You must initialize dst by pdbFileNew , before using it.

extern void pdbFileOneProteinCopy(pdbFile* dst, pdbFile* src, long num);

Secondary Structure

Read

Read Secondary Structure from pdb->PDB->FullRecord, and store to second.

extern int pdbSecondaryStructureSetFromPDB(pdbFile* pdb, pdbFileSecondaryStructure* second);

Read alpha carbon which is out of Secondary Structure from pdb->PDB->FullRecord, and store to second.

extern int pdbNoSecondaryStructureSetFromPDB(pdbFile* pdb, pdbFileSecondaryStructure* second);

Write

Write Secondary Structure second to file fpt as PDB. (Repeat to use pdbFileSecondaryStructureRecordPrint)

extern void pdbFileWriteSecondaryStructure(FILE* fpt, pdbFileSecondaryStructure* second);

Write 1 line Secondary Structure second to file fpt as PDB.

extern pdbFileSecondaryStructureRecord* pdbFileSecondaryStructureRecordPrint(FILE* fpt, pdbFileSecondaryStructureRecord* second);

Append

Create new Secondary Structure data to second, allocating memory.

extern int pdbSecondaryStructureAppend(pdbFileSecondaryStructure* second);

If second->nSecondaryStructure=0, set it to top data. In addition, set NULL to the previous and the next data.
Otherwise, set it to current data, original data to previous data, and original next data to next data.

data判定

If Secondary Structure(HELIX, SHEET, TURN), return 1. Otherwise, return 0.

extern long pdbFileIsSecondaryStructure(pdbFile* pdb);

If Helix Structure(HELIX), return 1. Otherwise, return 0.

extern long pdbFileIsHelix(pdbFile* pdb);

If Sheet Structure(SHEET), return 1. Otherwise, return 0.

extern long pdbFileIsSheet(pdbFile* pdb);

If Turn Structure(TURN), return 1. Otherwise, return 0.

extern long pdbFileIsTurn(pdbFile* pdb);

If pdb->PDB is included by second->SecondaryStructure, return the Secondary Structure data. Otherwise, return pdbFileSecondaryStructureModeNo.

extern pdbFileSecondaryStructureMode pdbFileWithSecondaryStructure(pdbFile* pdb, pdbFileSecondaryStructure* second);

Affine Transformation by Matrix

Read and Write file

Process file by using Matrix3D(API)#Read and Write file.

extern void pdbMatrixFileFormat(FILE* fpt);
extern void pdbMatrixFileRead(FILE* fpt, Matrix3D Matrix);
extern void pdbMatrixFileWrite(FILE* fpt, Matrix3D Matrix);

Affine Transformation

Perform Affine Trasformation by using Matrix.

extern void pdbTrans(pdbFile* pdb, Matrix3D Matrix);
extern void pdbTransCuda(float* hv, int n, Matrix3D Matrix);

Create a matrix by using Matrix3D(API)#Affine Matrix, and rotate pdb.
Rotation with Euler Angle

extern void pdbRotationFollowingEulerAngle(pdbFile* pdb, char Mode[4], pdbFileParaTypeReal rot1, pdbFileParaTypeReal rot2, pdbFileParaTypeReal rot3);
extern void pdbRotationFollowingEulerAngleInverse(pdbFile* pdb, char Mode[4], pdbFileParaTypeReal rot1, pdbFileParaTypeReal rot2, pdbFileParaTypeReal rot3);

Rotation by specified order for axis

extern void pdbRotationXYZ(pdbFile* pdb, pdbFileParaTypeReal rotx, pdbFileParaTypeReal roty, pdbFileParaTypeReal rotz);
extern void pdbRotationZYX(pdbFile* pdb, pdbFileParaTypeReal rotx, pdbFileParaTypeReal roty, pdbFileParaTypeReal rotz);
extern void pdbRotationZXY(pdbFile* pdb, pdbFileParaTypeReal rotx, pdbFileParaTypeReal roty, pdbFileParaTypeReal rotz);
extern void pdbRotationYXZ(pdbFile* pdb, pdbFileParaTypeReal rotx, pdbFileParaTypeReal roty, pdbFileParaTypeReal rotz);