" INSTALLATION: below you will find a line like: pq := PostgreSQL connectTo:'mydb' on:'localhost' at:'5432'. change the database name, hostname and port number to the values where MolTalk will find your local PostgreSQL database server. That's all. " [| "Read a PDB structure and derive some information" "everything gets entered into a relational database" main | sname arg s1 override | sname := nil. "holds the name of the structure file" override := 0. "0=do not override structure already in the db, 1=do reload into database" 1 to: (ARGS count) - 1 do: [ :argc | arg := (ARGS objectAtIndex:(argc intValue)). "Transcript showLine:('argument: ',argc stringValue, ' ', arg)." "check for input file name" (arg = '-i') ifTrue: [ targc := argc + 1. sname := (ARGS objectAtIndex:(targc)). ]. (arg = '-f') ifTrue: [ override := 1. ]. ]. (sname isNil) ifTrue: [ Transcript showLine:('no PDB code was given (parameter -i). Abort'). ^self ] ifFalse: [ s1 := self loadStrx:sname doOverride:override. ]. Transcript showLine:('all done.'). ^self ! " load the structure with the given name " loadStrx:sname doOverride:override | pq | "connect to the database" " >>>> >>>> >>>> >>>> change it here !!! " pq := PostgreSQL connectTo:'mydb' on:'localhost' at:'5432'. " <<<< <<<< <<<< <<<< " (pq notNil) ifTrue: [ pq query: ('select code from chsaw_pdb where code=\'',sname,'\' union select pdb from chsaw_chain where pdb=\'',sname,'\';'). (pq rows > 0) "check for structure-chains already in db" ifTrue: [ Transcript showLine: ('already have structure ',sname,' in database.'). (override=1) ifTrue: [ Transcript showLine: 'we do override!'. "remove current structure-chains in db" pq query: ('delete from chsaw_chain where pdb=\'',sname,'\';'). pq query: ('delete from chsaw_pdb where code=\'',sname,'\';'). "reload" self parseStrx:sname intoDB:pq. ]. ] ifFalse: [ "load structure-chains into db" self parseStrx:sname intoDB:pq. ]. ] ifFalse: [ Transcript showLine:'failed to connect to database server.' ]. pq disconnect. ^strx ! " parse information contained in structure " parseStrx:sname intoDB:pq | strx t1 | [ strx := StructureFactory newStructureFromPDBDirectory:sname. ] handler: [ :except | Transcript showLine:('EXCEPTION: ',except reason). ]. "load structure-chains into db" (strx notNil) ifTrue: [ Transcript showLine:('Structure: ', strx pdbcode). Transcript showLine:('Title: ', strx title). Transcript showLine:('Resolution: ', strx resolution stringValue). Transcript showLine:('Date: ', strx date description). Transcript showLine:('Rev. Date: ', strx revdate description). Transcript showLine:('Experiment: ', strx expdata stringValue). pq query:('insert into chsaw_pdb (code,deposited,lastrev,experiment,resolution,header,title) values(\'',strx pdbcode,'\',\'',strx date description,'\',\'',strx revdate description,'\',\'',strx expdata stringValue,'\',\'',strx resolution stringValue,'\',\'',strx header quoted,'\',\'',strx title quoted,'\');'). strx allChains allObjects do: [ :chain | self parseChain:chain intoDB:pq. ]. ]. ^self ! " give information about chain " parseChain:chain intoDB:pq | c1 | Transcript showLine:(' Chain: ', chain code stringValue, ' \'', chain name, '\''). Transcript showLine:(' Source: ', chain source). Transcript showLine:(' Compound: ', chain compound). Transcript showLine:(' E.C. code: ', chain eccode). Transcript showLine:(' Residues: ', chain countResidues stringValue). Transcript showLine:(' Amino Ac.: ', chain countStandardAminoAcids stringValue). Transcript showLine:(' Heterogens: ', chain countHeterogens stringValue). Transcript showLine:(' Solvent: ', chain countSolvent stringValue). Transcript showLine:(' Sequence: ', chain getSequence). Transcript showLine:''. pq query:('insert into chsaw_chain (pdb,code,residues,aminoacids,heterogens,solvent,sequence,organism,compound,eccode,chainid,chainid2) values(\'',chain structure pdbcode,'\',\'',chain name,'\',\'',chain countResidues stringValue,'\',\'',chain countStandardAminoAcids stringValue,'\',\'',chain countHeterogens stringValue,'\',\'',chain countSolvent stringValue,'\',\'',chain getSequence,'\',\'',chain source quoted,'\',\'',chain compound quoted,'\',\'',chain eccode,'\',\'',chain structure pdbcode,chain name,'\',\'',chain structure pdbcode,chain code stringValue,'\');'). ^self ]