NCBI C Toolkit Cross Reference

C/biostruc/getmmdb.c


  1 /* getmmdb.c */
  2 
  3 /* Get MMDB-derived Kinemages, PDB Files, Summaries using PDB acession numbers */
  4 
  5 #include <ncbi.h>  
  6 #include <asn.h>    
  7 #include <mmdbapi.h>   /* the MMDBAPI header */
  8 
  9  
 10 
 11 #define NUMARGS 6
 12 
 13 Args myargs[NUMARGS] = {
 14         {"Input PDB Accession ",NULL,NULL,NULL,FALSE,'i',ARG_STRING,0.0,0,NULL},
 15         {"OUTPUT Type \n0 = Summary File \n1 = PDB File, \n2 = Kinemage File", 
 16         "1","0","2",FALSE,'t',ARG_INT,0.0,0,NULL},
 17         {"Output File Name",NULL,NULL,NULL,TRUE,'o',ARG_FILE_OUT,0.0,0,NULL},
 18         {"Model Level \n0 = All Atom; 1=BackBone; 2=PDB models; 3=Vector; ","0","0","3",TRUE,'m',ARG_INT,0.0,0,NULL},
 19         {"Kinemage Color Type \n0=Default, 1=By Number, 2=By Type, 3=By Temp, 4=By Atom", 
 20         "0","0","4",FALSE,'c',ARG_INT,0.0,0,NULL},
 21         {"Kinemage Rendering \n0=V+HET; 11=...+BB; 15=...+RES; 31=...+ALT; 63=...+NMR ", 
 22         "0","0","63",FALSE,'r',ARG_INT,0.0,0,NULL}
 23 
 24       };
 25 
 26 
 27  
 28 
 29 Nlm_Int2 Main ()
 30 {
 31   Int2 iTest;
 32   Byte bRender;
 33   Int2 iColor; 
 34   PDNMS pdnmsModelstruc;
 35   BiostrucPtr pbsBiostruc;
 36   Char cOut[254];
 37   FILE *pFile;
 38   
 39         ErrSetFatalLevel(SEV_MAX);
 40         
 41         if (! GetArgs("GetMMDB",NUMARGS,myargs))
 42                 return 1;
 43          
 44         /* Initialize MMDBAPI  */ 
 45 
 46         if (! OpenMMDBAPI(0, NULL)) 
 47           {
 48                 printf("Have not opened mmdbapi");
 49                 return 2;       
 50           }
 51           
 52         /* load an ASN.1 Biostruc */
 53         /* Any other method of obtaining a Biostruc is fine... */
 54         /* This one does a built-in lookup of PDB accesion numbers */
 55         /* then fetches the file using the Entrez clinet-server interface */
 56         pbsBiostruc = FetchBiostrucPDB(myargs[0].strvalue, myargs[3].intvalue, 100);
 57         if (pbsBiostruc == NULL)
 58           {
 59                 printf("Have not fetched Biostruc");
 60                 return 3;
 61           }
 62 
 63         /* convert it into a Modelstruc pointed to by pdnmsModelstruc */
 64         pdnmsModelstruc= MakeAModelstruc(pbsBiostruc);          
 65         if ( pdnmsModelstruc == NULL )
 66           {
 67                 printf("Have not converted Biostruc");
 68                 return 4;
 69           }
 70                  
 71         if (myargs[1].intvalue == 0) /* Summary */
 72           {
 73              if (!myargs[2].strvalue)
 74               { 
 75                 sprintf(cOut,"%s.sum",  myargs[0].strvalue);    
 76                 pFile = fopen(cOut, "w");
 77               }   
 78             else  
 79                pFile = fopen(myargs[2].strvalue,"w");
 80             iTest = WriteStructSummary(pdnmsModelstruc,pFile); 
 81           }
 82          
 83         if (myargs[1].intvalue == 2) /* Kinemage */
 84           {
 85             bRender = (Byte) myargs[5].intvalue;
 86             iColor = (Int2) myargs[4].intvalue;
 87             if (!myargs[2].strvalue)
 88               { 
 89                 sprintf(cOut,"%s.kin",  myargs[0].strvalue);    
 90                 pFile = fopen(cOut, "w");
 91               }   
 92             else  
 93                pFile = fopen(myargs[2].strvalue,"w");
 94             iTest = WriteKinAllModel(pdnmsModelstruc,pFile,
 95                                         iColor,bRender);
 96                                         
 97           }
 98                     
 99         if (myargs[1].intvalue == 1) /* PDB */
100           {
101             if (!myargs[2].strvalue)
102               { 
103                 sprintf(cOut,"%s.pdb",  myargs[0].strvalue);    
104                 pFile = fopen(cOut, "w");
105               }   
106             else  
107                pFile = fopen(myargs[2].strvalue,"w");
108             iTest = WritePDBAllModel(pdnmsModelstruc,pFile);
109           }
110         
111         /* Free the Modelstruc (and its enclosed Biostruc) */     
112         /* FreeAModelstruc(PDNMS pdnmsThis); not necessary */
113         /* This can be done individually - but all Modelstrucs */
114         /* remaining are freed in CloseMMDBAPI() */
115 
116         /* Shut Down MMDBAPI */ 
117 
118         CloseMMDBAPI(); 
119 
120         return TRUE;
121 }
122 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.