# include "dist.h" # define HELP_STRING "\ \n\ Options: \n\ -Fixed = Filename of Fixed Structure \n\ -Moving = Filename of Moving Structure \n\ -Output = Filename to output (transformed) Moving Structure \n\ -Selection = Filename of CA Selections ( '-' = stdin ) \n\ -VerboseDumpRT = Print out transformation with rotation angle and axis \n\ -SimpleDumpRT = Print out transformation in a simple form \n\ -DoTransRot = Apply transformation to coordinates \n\ -SelectAll = Select All Atoms \n\ -VerifySelect = Dump the selected atoms for verification \n\ -CompareCoordinates = Compare CAs \n\ \n\ " # define HELP_STRING2 "\ Selection File Format : \n\ File = StrucSel-for-fixed StrucSel-for-moving \n\ StrucSel = { \\n Range [ \\n range] \\n } \\n \n\ Range = from-integer to-integer chain-char \n\ If chain is '_' or NULL, chain is ' '. \n\ Example : \n\ Fixed \n\ { \n\ 1 10 A \n\ 20 30 A \n\ } \n\ Moving \n\ { \n\ 10 20 \n\ 40 50 \n\ } \n\ \n\ Normal Output Format is : \n\ Rotation[3,3] \\n Translation[3] \\n RMS[1] \n\ " main(int argc,char ** argv) { SAY_HI_FIRST; CITATION ; do_initialization(0,0) ; if (OPT("help")) { printf(HELP_STRING); printf(HELP_STRING2); } else { char *MovingFileName = StringAfterOption(argc,argv,"Moving", "Moving.pdb"), *FixedFileName = StringAfterOption(argc,argv,"Fixed", "Fixed.pdb"), *OutputFileName = StringAfterOption(argc,argv,"Output", NULL); file_records *Moving = open_and_read_pdb(MovingFileName,0), *Fixed = open_and_read_pdb(FixedFileName,0); int nsel1, nsel2 ; if (OPT("SelectAll")) { FlagOffEverywhere(Fixed,FLAG_1_DESELECT|FLAG_2_DESELECT); FlagOffEverywhere(Moving,FLAG_1_DESELECT|FLAG_2_DESELECT); } else if (OPT("EquivSelect")) { TokenizeData d = {0}; d.filename = StringAfterOption(argc,argv,"EquivSelect","Selection.txt"); InitLexer(&d); d.whitespace = " -\t\n" ; fprintf(stderr,"MyFit.c: EquivSelectCA(): Fixed=%s Moving=%s\n",FixedFileName,MovingFileName); nsel1 = nsel2 = EquivSelectCA(Fixed,Moving,&d); } else { TokenizeData d = {0}; d.filename = StringAfterOption(argc,argv,"Selection","Selection.txt"); InitLexer(&d); d.whitespace = " -\t\n" ; fprintf(stderr,"[ MyFit.c ] Selection from Fixed Structure %s\n",FixedFileName); nsel1 = NSelectCA(Fixed,&d) ; fprintf(stderr,"[ MyFit.c ] Selection from Moving Structure %s\n",MovingFileName); nsel2 = NSelectCA(Moving,&d); if (nsel1 != nsel2) STDERR("nsel1 != nsel2") ; } if (OPT("VerifySelect")) { printf("Selected Atoms from Fixed Structure: \n"); write_pdb_file(stdout,Fixed,IO_ONLY_SELECTED); printf("Selected Atoms from Moving Structure: \n"); write_pdb_file(stdout,Moving,IO_ONLY_SELECTED); } { double ** RotMat = dmatrix(1,3,1,3) ; double TVect[4]; double rms ; if (OPT("MyFit")) { rms = MyFit(RotMat,TVect,Moving,Fixed); } else if (OPT("FindFitTranslationOnly")) { IdentityMatrix(RotMat); FindFitTranslationOnly(TVect,Moving,Fixed); rms = 0; } else if (OPT("FitTR")) { AllocateNRVect3 TVect2; FindFitTranslationOnly(TVect,Moving,Fixed); TranslateCoordinates(Moving,TVect); rms = MyFit(RotMat,TVect2,Moving,Fixed); STDERR("FitTR means doing translation first."); fprintf(stderr, "The secondary translation, which is ( %6.3f %6.3f %6.3f ), should be (0 0 0)\n", TVect2[1],TVect2[2],TVect2[3]); TVect2[1]= -TVect[1]; TVect2[2]= -TVect[2]; TVect2[3]= -TVect[3]; TranslateCoordinates(Moving,TVect2); } if (OPT("SimpleDumpRT")) SimpleDumpRT(RotMat,TVect,rms); if (OPT("DoTransRot")) { if (OPT("FitTR")) { RotateCoordinates(Moving,RotMat); TranslateCoordinates(Moving,TVect); } else { TranslateCoordinates(Moving,TVect); RotateCoordinates(Moving,RotMat); } } if (OPT("CompareCoordinates")) { double rms2 = CompareCoordinatesSecondToFirst(Fixed,Moving,FLAG_2_DESELECT); FTOE(rms2); } } if (OutputFileName) { FILE * OutputStream = fopen(OutputFileName,"w"); if (OPT("WriteOnlySelected")) { write_pdb_file(OutputStream,Moving,IO_ONLY_SELECTED); } else { write_pdb_file(OutputStream,Moving,0); } } } exit(0); }