*** command.c Mon Apr 25 08:31:12 2005 --- command.c Tue May 2 22:37:16 2006 *************** *** 4312,4323 **** } else switch(option) { case(NMRPDBTok): ! case(PDBTok): SavePDBMolecule(param); break; ! case(MDLTok): SaveMDLMolecule(param); break; ! case(XYZTok): SaveXYZMolecule(param); break; ! case(CIFTok): SaveCIFMolecule(param); break; #ifdef CEXIOLIB ! case(CEXTok): SaveCEXMolecule(param); break; #endif case(AlchemyTok): SaveAlchemyMolecule(param); break; --- 4312,4324 ---- } else switch(option) { case(NMRPDBTok): ! case(PDBTok): SavePDBMolecule(param); break; ! case(WPDBTok): SaveWPDBMolecule(param); break; ! case(MDLTok): SaveMDLMolecule(param); break; ! case(XYZTok): SaveXYZMolecule(param); break; ! case(CIFTok): SaveCIFMolecule(param); break; #ifdef CEXIOLIB ! case(CEXTok): SaveCEXMolecule(param); break; #endif case(AlchemyTok): SaveAlchemyMolecule(param); break; *** command.h Mon Apr 25 08:31:12 2005 --- command.h Tue May 2 22:44:13 2006 *************** *** 100,105 **** --- 100,106 ---- #define FormatXYZ 14 #define FormatCIF 15 #define FormatCEX 16 + #define FormatWPDB 17 #define FormatDots 20 *** infile.c Sat Apr 22 15:25:45 2006 --- infile.c Tue May 2 23:24:44 2006 *************** *** 177,183 **** static RAtom __far *ConnectAtom; static char __far Record[256]; static FILE *DataFile; ! /*=======================*/ --- 177,183 ---- static RAtom __far *ConnectAtom; static char __far Record[256]; static FILE *DataFile; ! static int WPDB; /*=======================*/ *************** *** 590,603 **** static Long ReadPDBCoord( int offset ) { ! register int len,neg; register Long result; register char *ptr; register char ch; result = 0; neg = False; len = 8; ptr = Record+offset; while( len-- ) --- 590,605 ---- static Long ReadPDBCoord( int offset ) { ! register int len,neg,decpos; register Long result; register char *ptr; register char ch; result = 0; neg = False; + decpos = -1; len = 8; + if (WPDB) len = 13; ptr = Record+offset; while( len-- ) *************** *** 605,630 **** if( (ch>='0') && (ch<='9') ) { result = (10*result)+(ch-'0'); } else if( ch=='-' ) neg = True; ! } ! ! /* Handle Chem3D PDB Files! */ ! if( Record[offset+3]=='.' ) ! result /= 10; ! return( neg? -result : result ); } static void ProcessPDBGroup( int heta, int serno ) { ! PDBInsert = Record[26]; ! if( !CurChain || (CurChain->ident!=Record[21]) ) { ConnectAtom = (RAtom __far*)0; ! CreateChain( Record[21] ); } CreateGroup( GroupPool ); ! CurGroup->refno = FindResNo( Record+17 ); CurGroup->serno = serno; ProcessGroup( heta ); } --- 607,645 ---- if( (ch>='0') && (ch<='9') ) { result = (10*result)+(ch-'0'); } else if( ch=='-' ) + { neg = True; ! } else if (ch=='.') ! { ! decpos = len; ! } else if (ch==' ') ! { ! result *= 10; ! } ! } ! if (decpos == -1) { ! if (WPDB) result /= 100; ! } else { ! decpos -= 3; ! while (decpos > 0) { ! result /= 10; ! decpos--; ! } ! } ! return( neg? -result : result ); } static void ProcessPDBGroup( int heta, int serno ) { ! PDBInsert = Record[WPDB?64:26]; ! if( !CurChain || (CurChain->ident!=Record[WPDB?54:21]) ) { ConnectAtom = (RAtom __far*)0; ! CreateChain( Record[WPDB?54:21] ); } CreateGroup( GroupPool ); ! CurGroup->refno = FindResNo( Record+(WPDB?42:17) ); CurGroup->serno = serno; ProcessGroup( heta ); } *************** *** 637,649 **** register Long dx,dy,dz; register int temp,serno; ! dx = ReadPDBCoord(30); ! dy = ReadPDBCoord(38); ! dz = ReadPDBCoord(46); /* Process Pseudo Atoms Limits!! */ ! if( (Record[13]=='Q') && (Record[12]==' ') ) ! { temp = (int)ReadValue(60,6); if( MMinMaxFlag ) { if( temp < MinMainTemp ) { MinMainTemp = temp; --- 652,676 ---- register Long dx,dy,dz; register int temp,serno; ! if (WPDB) { ! dx = ReadPDBCoord(65); ! dy = ReadPDBCoord(78); ! dz = ReadPDBCoord(91); ! } else { ! dx = ReadPDBCoord(30); ! dy = ReadPDBCoord(38); ! dz = ReadPDBCoord(46); ! } /* Process Pseudo Atoms Limits!! */ ! ! if( (WPDB && (Record[23]=='Q') && (Record[22]==' ')) || ! ( (!WPDB) && (Record[13]=='Q') && (Record[12]==' ') )) ! { if (WPDB) { ! temp = (int)ReadValue(110,6); ! } else { ! temp = (int)ReadValue(60,6); ! } if( MMinMaxFlag ) { if( temp < MinMainTemp ) { MinMainTemp = temp; *************** *** 681,693 **** --- 708,729 ---- if( (dx==9999000L) && (dy==9999000L) && (dz==9999000L) ) return; + if (WPDB) { + serno = (int)ReadValue(55,9); + if( !CurGroup || (CurGroup->serno!=serno) + || (CurChain->ident!=Record[54]) + || (PDBInsert!=Record[64]) ) + ProcessPDBGroup( heta, serno ); + } else { serno = (int)ReadValue(22,4); if( !CurGroup || (CurGroup->serno!=serno) || (CurChain->ident!=Record[21]) || (PDBInsert!=Record[26]) ) ProcessPDBGroup( heta, serno ); + } /* Handle Strange PDB Files */ + if (!WPDB) { if( (Record[12]==' ') && (Record[13]==' ') ) { /* Right Justified Atom Name! */ if( Record[14] == ' ' ) *************** *** 699,716 **** Record[15] = ' '; } } ptr = CreateAtom(); ! ptr->refno = ComplexAtomType(Record+12); ! ptr->serno = ReadValue(6,5); ! ptr->temp = (int)ReadValue(60,6); ! ptr->altl = Record[16]; ptr->model = NMRModel; /* Handle CONCORD PDB Files */ if( (Record[12]==' ') && islower(Record[14]) && !strncmp(Record+15," ",7) ) ptr->refno = SimpleAtomType(Record+13); ptr->xorg = dx/4; ptr->yorg = dy/4; --- 735,755 ---- Record[15] = ' '; } } + } ptr = CreateAtom(); ! ptr->refno = ComplexAtomType(Record+(WPDB?22:12)); ! ptr->serno = ReadValue(WPDB?8:6,WPDB?9:5); ! ptr->temp = (int)ReadValue(WPDB?110:60,6); ! ptr->altl = Record[WPDB?32:16]; ptr->model = NMRModel; /* Handle CONCORD PDB Files */ + if (!WPDB) { if( (Record[12]==' ') && islower(Record[14]) && !strncmp(Record+15," ",7) ) ptr->refno = SimpleAtomType(Record+13); + } ptr->xorg = dx/4; ptr->yorg = dy/4; *************** *** 757,776 **** len = strlen(Record); if( len < (size_t)16 ) return; ! srcatm = (Long)ReadValue(6,5); if( !srcatm ) return; ! for( i=11; i<=26 && Record[i]; i+=5 ) ! { if( len < (size_t)(i+5) ) return; ! dstatm = (Long)ReadValue(i,5); if( dstatm ) CreateNewBond(srcatm,dstatm); } ! for( i=31; i<=56 && Record[i]; i+=5 ) ! { if( len < (size_t)(i+5) ) return; ! dstatm = (int)ReadValue(i,5); ! if( i < 41 || (i > 45 && i < 56)) { if( dstatm && srcatm < dstatm ) CreateBond(srcatm,dstatm,HydrBondFlag); } else { --- 796,815 ---- len = strlen(Record); if( len < (size_t)16 ) return; ! srcatm = (Long)ReadValue(WPDB?22:6,WPDB?9:5); if( !srcatm ) return; ! for( i=(WPDB?32:11); i<=(WPDB?62:26) && Record[i]; i+=(WPDB?10:5) ) ! { if( len < (size_t)(i+(WPDB?9:5)) ) return; ! dstatm = (Long)ReadValue(i,WPDB?9:5); if( dstatm ) CreateNewBond(srcatm,dstatm); } ! for( i=(WPDB?72:31); i<=(WPDB?122:56) && Record[i]; i+=(WPDB?10:5) ) ! { if( len < (size_t)(i+(WPDB?9:5)) ) return; ! dstatm = (int)ReadValue(i,WPDB?9:5); ! if( i < (WPDB?92:41) || (i > (WPDB?101:45) && i < (WPDB?122:56))) { if( dstatm && srcatm < dstatm ) CreateBond(srcatm,dstatm,HydrBondFlag); } else { *************** *** 822,841 **** register char *src; register char *dst; ! dst = Info.spacegroup; src=Record+55; ! while( *src && srctype = FeatSheet; ! ptr->chain = Record[21]; ! ptr->init = (int)ReadValue(22,4); ! ptr->term = (int)ReadValue(33,4); } else if (!strncmp("SCAL",Record,4) ) { int rownum; rownum = (int)ReadValue(5,1); if ((rownum > 0) && (rownum < 4) ) { ! Info.mato2f[rownum-1][0] = ReadDecValue(10,10); ! Info.mato2f[rownum-1][1] = ReadDecValue(20,10); ! Info.mato2f[rownum-1][2] = ReadDecValue(30,10); ! Info.veco2f[rownum-1] = ReadDecValue(45,10); if (rownum == 3) { if (invxfrm(Info.mato2f,Info.veco2f, Info.matf2o,Info.vecf2o) ) { --- 997,1042 ---- } break; ! case('L'): if( !strncmp("LEAD",Record,4) ) ! { ExtractString(60,Record+22, ! Info.classification); ! ExtractString(15,Record+95,Info.identcode); ! ExtractString(11,Record+83,Info.date); ! WPDB = True; ! } ! break; ! ! case('M'): if( !strncmp("MODE",Record,4) ) { ! if(WPDB) { ! NMRModel = (int)ReadValue(8,9); ! } else { ! NMRModel = (int)ReadValue(10,5); ! } flag = True; + } break; case('S'): if( !strncmp("SHEE",Record,4) ) { if( ignore ) break; + if (WPDB && (Record[6]!='S')) break; /* Remaining SHEET record fields */ /* 38-39 .... Strand Parallelism */ /* 32 ....... Same Chain as 21? */ ptr = AllocFeature(); ptr->type = FeatSheet; ! ptr->chain = Record[WPDB?52:21]; ! ptr->init = (int)ReadValue(WPDB?53:22,WPDB?9:4); ! ptr->term = (int)ReadValue(WPDB?84:33,WPDB?9:4); } else if (!strncmp("SCAL",Record,4) ) { int rownum; rownum = (int)ReadValue(5,1); if ((rownum > 0) && (rownum < 4) ) { ! Info.mato2f[rownum-1][0] = ReadDecValue(WPDB?22:10,WPDB?13:10); ! Info.mato2f[rownum-1][1] = ReadDecValue(WPDB?36:20,WPDB?13:10); ! Info.mato2f[rownum-1][2] = ReadDecValue(WPDB?50:30,WPDB?13:10); ! Info.veco2f[rownum-1] = ReadDecValue(WPDB?64:45,WPDB?13:10); if (rownum == 3) { if (invxfrm(Info.mato2f,Info.veco2f, Info.matf2o,Info.vecf2o) ) { *************** *** 1006,1014 **** ptr = AllocFeature(); ptr->type = FeatTurn; ! ptr->chain = Record[19]; ! ptr->init = (int)ReadValue(20,4); ! ptr->term = (int)ReadValue(31,4); } else if( !strncmp("TER",Record,3) ) { if( !Record[3] || (Record[3]==' ') ) { ConnectAtom = (void __far*)0; --- 1063,1071 ---- ptr = AllocFeature(); ptr->type = FeatTurn; ! ptr->chain = Record[WPDB?52:19]; ! ptr->init = (int)ReadValue(WPDB?53:20,WPDB?9:4); ! ptr->term = (int)ReadValue(WPDB?84:31,WPDB?9:4); } else if( !strncmp("TER",Record,3) ) { if( !Record[3] || (Record[3]==' ') ) { ConnectAtom = (void __far*)0; *************** *** 3047,3053 **** y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 +(double)(aptr->ytrl)/10000.0; z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 ! +(double)(aptr->ztrl)/10000.0; #ifdef INVERT fprintf(DataFile,"%8.3f%8.3f%8.3f",x,-y,-z); --- 3104,3110 ---- y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 +(double)(aptr->ytrl)/10000.0; z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 ! -(double)(aptr->ztrl)/10000.0; #ifdef INVERT fprintf(DataFile,"%8.3f%8.3f%8.3f",x,-y,-z); *************** *** 3072,3077 **** --- 3129,3232 ---- #endif return True; } + + + /*=================================*/ + /* Molecule File Format Generation */ + /*=================================*/ + + int SaveWPDBMolecule( char *filename ) + { + register double x, y, z; + register Group __far *prev; + register Chain __far *chain; + register Group __far *group; + register RAtom __far *aptr; + register char *ptr; + register int count; + register int model; + register char ch = '\0'; + register int i; + + if( !Database ) + return False; + + DataFile = fopen( filename, "w" ); + if( !DataFile ) + { InvalidateCmndLine(); + WriteString("Error: Unable to create file!\n\n"); + return False; + } + + if( *Info.classification || *Info.identcode ) + { fputs("LEADER 1 ",DataFile); + + ptr = Info.classification; + for( i=23; i<=83; i++ ) + putc( (*ptr ? *ptr++ : ' '), DataFile ); + fprintf(DataFile,"%-11.11s%-15.15s\n",Info.date,Info.identcode); + } + + if( *Info.moleculename ) + fprintf(DataFile,"COMPND %.110s\n",Info.moleculename); + if( *Info.technique ) + fprintf(DataFile,"EXPDTA %.110s\n",Info.technique); + + prev = (void __far*)0; + count = 1; + model = 0; + ch = ' '; + + ForEachAtom + if( aptr->flag&SelectFlag ) + { if( prev && (chain->ident!=ch) ) + fprintf( DataFile, "TER %9d %10.10s %c%9d \n", + count++, Residue[prev->refno], ch, prev->serno); + if( chain->model != model ) + { if( model ) + fputs("ENDMDL\n",DataFile); + fprintf(DataFile,"MODEL %9d\n",chain->model); + model = chain->model; + } + + if( aptr->flag&HeteroFlag ) + { fputs("HETATM ",DataFile); + } else fputs("ATOM ",DataFile); + fprintf( DataFile, "%9d %-10.10s %c%10.10s %c%9d ", + count++, ElemDesc[aptr->refno], + aptr->altl, Residue[group->refno], + chain->ident, group->serno ); + + x = (double)(aptr->xorg + aptr->fxorg + OrigCX)/250.0 + +(double)(aptr->xtrl)/10000.0; + y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 + +(double)(aptr->ytrl)/10000.0; + z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 + -(double)(aptr->ztrl)/10000.0; + + #ifdef INVERT + fprintf(DataFile,"%13.5f%13.5f%13.5f",x,-y,-z); + #else + fprintf(DataFile,"%13.5f%13.5f%13.5f",x,y,-z); + #endif + fprintf(DataFile," 1.00%6.2f\n",aptr->temp/100.0); + + ch = chain->ident; + prev = group; + } + + if( prev ) + fprintf( DataFile, "TER %9d %10.10s %c%9d \n", + count, Residue[prev->refno], ch, prev->serno); + if( model ) + fputs("ENDMDL\n",DataFile); + fputs("END \n",DataFile); + fclose( DataFile ); + #ifdef APPLEMAC + SetFileInfo(filename,'RSML','TEXT',131); + #endif + return True; + } int SaveMDLMolecule( char *filename ) *************** *** 3134,3140 **** y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 +(double)(aptr->ytrl)/10000.0; z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 ! +(double)(aptr->ztrl)/10000.0; #ifdef INVERT #ifdef __STDC__ fprintf(DataFile,"%10.4f%10.4f%10.4f ",x,-y,-z); --- 3289,3295 ---- y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 +(double)(aptr->ytrl)/10000.0; z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 ! -(double)(aptr->ztrl)/10000.0; #ifdef INVERT #ifdef __STDC__ fprintf(DataFile,"%10.4f%10.4f%10.4f ",x,-y,-z); *************** *** 3287,3293 **** y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 +(double)(aptr->ytrl)/10000.0; z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 ! +(double)(aptr->ztrl)/10000.0; /* Apply Current Viewpoint Rotation Matrix */ xpos = (float)(x*RotX[0] + y*RotX[1] + z*RotX[2]); --- 3442,3448 ---- y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 +(double)(aptr->ytrl)/10000.0; z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 ! -(double)(aptr->ztrl)/10000.0; /* Apply Current Viewpoint Rotation Matrix */ xpos = (float)(x*RotX[0] + y*RotX[1] + z*RotX[2]); *************** *** 3365,3371 **** y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 +(double)(aptr->ytrl)/10000.0; z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 ! +(double)(aptr->ztrl)/10000.0; #ifdef INVERT fprintf(DataFile," %8.3f %8.3f %8.3f",x,-y,-z); --- 3520,3526 ---- y = (double)(aptr->yorg + aptr->fyorg + OrigCY)/250.0 +(double)(aptr->ytrl)/10000.0; z = (double)(aptr->zorg + aptr->fzorg + OrigCZ)/250.0 ! -(double)(aptr->ztrl)/10000.0; #ifdef INVERT fprintf(DataFile," %8.3f %8.3f %8.3f",x,-y,-z); *** infile.h Mon Apr 25 08:31:12 2005 --- infile.h Tue May 2 22:38:12 2006 *************** *** 94,99 **** --- 94,100 ---- int SaveAlchemyMolecule( char* ); int SavePDBMolecule( char* ); + int SaveWPDBMolecule( char* ); int SaveMDLMolecule( char* ); int SaveXYZMolecule( char* ); int SaveCIFMolecule( char* ); *** molecule.h Mon Apr 25 08:31:12 2005 --- molecule.h Sun Aug 7 17:33:31 2005 *************** *** 338,349 **** typedef struct _InfoStruct { char filename[1024]; char moleculename[80]; ! char classification[42]; char date[12]; ! char technique[80]; char identcode[80]; ! char spacegroup[12]; Real cellalpha, cellbeta, cellgamma; Real cella, cellb, cellc; --- 338,349 ---- typedef struct _InfoStruct { char filename[1024]; char moleculename[80]; ! char classification[62]; char date[12]; ! char technique[110]; char identcode[80]; ! char spacegroup[14]; Real cellalpha, cellbeta, cellgamma; Real cella, cellb, cellc; *** tokens.c Mon Apr 25 08:31:12 2005 --- tokens.c Tue May 2 22:46:31 2006 *************** *** 313,319 **** COORDS CoordTok COPY CopyTok CPK CPKTok ! CPKNEW CpkNewTok CYAN CyanTok CYCLIC CyclicTok CYSTINE CystineTok --- 313,319 ---- COORDS CoordTok COPY CopyTok CPK CPKTok ! CPKNEW CpkNewTok CYAN CyanTok CYCLIC CyclicTok CYSTINE CystineTok *************** *** 857,862 **** --- 857,863 ---- LABEL LabelTok LABELS LabelTok LARGE LargeTok + LEADER HeaderTok LIGAND LigandTok LIGANDS LigandTok LOAD LoadTok *************** *** 873,878 **** --- 874,885 ---- return( LargeTok ); } break; + + case('E'): + if( !strcmp(ptr,"ADER") ) { + return( HeaderTok ); + } + break; case('I'): if( !strcmp(ptr,"GAND") ) { *************** *** 1702,1707 **** --- 1709,1715 ---- WHITE WhiteTok WIREFRAME WireframeTok WITHIN WithinTok + WPDB WPDBTok WRITE WriteTok */ *************** *** 1730,1735 **** --- 1738,1749 ---- return( WithinTok ); } break; + + case('P'): + if( !strcmp(ptr,"DB") ) { + return( WPDBTok ); + } + break; case('R'): if( !strcmp(ptr,"ITE") ) { *** tokens.h Tue Apr 26 22:43:22 2005 --- tokens.h Tue May 2 22:40:39 2006 *************** *** 207,213 **** /* File Format Tokens */ /* Warning! Tokens are related to Format values */ ! #define IsMoleculeToken(x) (((x)>=360) && ((x)<=375)) #define PDBTok 360 #define MacroModelTok 361 --- 207,213 ---- /* File Format Tokens */ /* Warning! Tokens are related to Format values */ ! #define IsMoleculeToken(x) (((x)>=360) && ((x)<=376)) #define PDBTok 360 #define MacroModelTok 361 *************** *** 225,230 **** --- 225,231 ---- #define XYZTok 373 #define CIFTok 374 #define CEXTok 375 + #define WPDBTok 376 /* Raster Tokens */ #define IsImageToken(x) (((((x)>=380) && ((x)<=398)) || ((x) == PhiPsiTok)))