-
Notifications
You must be signed in to change notification settings - Fork 1
/
molscr.c
72 lines (53 loc) · 2.16 KB
/
molscr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "stride.h"
int MolScript(CHAIN **Chain, int NChain, COMMAND *Cmd)
{
int HelixBound[MAX_ASSIGN][2], SheetBound[MAX_ASSIGN][2], CoilBound[MAX_ASSIGN][2];
int NHelix, NSheet, NCoil, i, Cn;
char *Asn;
FILE *fi;
if( !(fi = fopen(Cmd->MolScriptFile,"w")) )
return(escape(FAILURE,"\nCan not open molscript file %s\n\n",Cmd->MolScriptFile));
fprintf(fi,"plot\n");
fprintf(fi,"read mol \"%s\";\n",Chain[0]->File);
fprintf(fi,"transform atom * by centre position in amino-acids\n");
fprintf(fi,"by rotation z 0.0 \n");
fprintf(fi,"by rotation y -260.0 \n");
fprintf(fi,"by rotation x -40.0;\n");
for( Cn=0; Cn<NChain; Cn++ ) {
if( !Chain[Cn]->Valid )
continue;
Asn = (char *)ckalloc(Chain[Cn]->NRes*sizeof(char));
ExtractAsn(Chain,Cn,Asn);
for( i=0; i<Chain[Cn]->NRes; i++ )
if( Asn[i] != 'H' && Asn[i] != 'E' )
Asn[i] = 'C';
NHelix = Boundaries(Asn,Chain[Cn]->NRes,'H',HelixBound);
NSheet = Boundaries(Asn,Chain[Cn]->NRes,'E',SheetBound);
NCoil = Boundaries(Asn,Chain[Cn]->NRes,'C',CoilBound);
free(Asn);
for( i=0; i<NSheet; i++ )
if( SheetBound[i][1] != Chain[Cn]->NRes-1 )
SheetBound[i][1]++;
for( i=0; i<NHelix; i++ )
if( HelixBound[i][1] != Chain[Cn]->NRes-1 )
HelixBound[i][1]++;
for( i=0; i<NCoil; i++ )
if( CoilBound[i][1] != Chain[Cn]->NRes-1 )
CoilBound[i][1]++;
for( i=0; i<NHelix; i++ )
fprintf(fi,"helix from %c%s to %c%s;\n",
Chain[Cn]->Id,Chain[Cn]->Rsd[HelixBound[i][0]]->PDB_ResNumb,
Chain[Cn]->Id,Chain[Cn]->Rsd[HelixBound[i][1]]->PDB_ResNumb);
for( i=0; i<NSheet; i++ )
fprintf(fi,"strand from %c%s to %c%s;\n",
Chain[Cn]->Id,Chain[Cn]->Rsd[SheetBound[i][0]]->PDB_ResNumb,
Chain[Cn]->Id,Chain[Cn]->Rsd[SheetBound[i][1]]->PDB_ResNumb);
for( i=0; i<NCoil; i++ )
fprintf(fi,"coil from %c%s to %c%s;\n",
Chain[Cn]->Id,Chain[Cn]->Rsd[CoilBound[i][0]]->PDB_ResNumb,
Chain[Cn]->Id,Chain[Cn]->Rsd[CoilBound[i][1]]->PDB_ResNumb);
}
fprintf(fi,"end_plot\n");
fclose(fi);
return(SUCCESS);
}