/*************************************************************************** blast_mod.cpp - description ------------------- begin : Tue Jun 27 08:12:04 2006 copyright : (C) 2002 by Cavalli Andrea email : cavalli@bioc.unizh.ch **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include #include #include #include #include #include #include using namespace Almost; template<> inline string to_string(const Blast &){ return ""; } template<> inline string to_string(const Blast::Hsp &){ return ""; } template<> inline string to_string(const Psipred &){ return ""; } template< typename Type> string str_cast(Type t){ stringstream s; s<Value()<FirstChildElement("BlastOutput_program"); if(child){ cout<Value()<<" "<GetText()<FirstChildElement("BlastOutput_version"); if(child){ cout<Value()<<" "<GetText()<FirstChildElement("BlastOutput_reference"); if(child){ cout<Value()<<" "<GetText()<FirstChildElement("BlastOutput_db"); if(child){ cout<Value()<<" "<GetText()<FirstChildElement("BlastOutput_query-ID"); if(child){ query_.id = child->GetText(); } } { child = root->FirstChildElement("BlastOutput_query-def"); if(child){ query_.def = child->GetText(); } } { child = root->FirstChildElement("BlastOutput_query-len"); if(child){ query_.len = atoi(child->GetText()); } } { child = root->FirstChildElement("BlastOutput_param"); if(child){ parse_blast_param(child->FirstChildElement()); } } { child = root->FirstChildElement("BlastOutput_iterations"); if(child){ parse_blast_iterations(child); } } } } void Blast::parse_blast_iterations(const TiXmlElement * iters){ const TiXmlElement * iter; for(iter = iters->FirstChildElement("Iteration");iter; iter = iter->NextSiblingElement ("Iteration")){ // cerr<<"DEBUG process iteration "; hits.resize(hits.size()+1); // cerr<FirstChildElement("Iteration_hits"); if(!iter_hits) { cout<<"NO HITS "<FirstChildElement("Hit");hit; hit = hit->NextSiblingElement ("Hit")){ // cout<<"DEBUG process Hit\n"; Hit h; h.iteration = hits.size(); { const TiXmlElement * res = hit->FirstChildElement("Hit_num"); if(res){ h.num = atoi(res->GetText()); // cout<<"DEBUG num "<FirstChildElement("Hit_id"); if(res){ h.id = res->GetText(); // cout<<"DEBUG id "<FirstChildElement("Hit_def"); if(res){ h.def = res->GetText(); // cout<<"DEBUG def "<FirstChildElement("Hit_accession"); if(res){ h.accession = res->GetText(); // cout<<"DEBUG accession "<FirstChildElement("Hit_len"); if(res){ h.len = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hit_hsps"); for(hsp = hsps->FirstChildElement("Hsp"); hsp; hsp = hsp->NextSiblingElement ("Hsp")){ Hsp hsp_; parse_blast_hsp(hsp,hsp_); h.hsp.push_back(hsp_); } hits.back().push_back(h); } } void Blast::parse_blast_hsp(const TiXmlElement * hsp,Hsp & hsp_){ { const TiXmlElement * res = hsp->FirstChildElement("Hsp_num"); if(res){ hsp_.num = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_bit-score"); if(res){ hsp_.bit_score = atof(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_score"); if(res){ hsp_.score = atof(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_evalue"); if(res){ hsp_.evalue = atof(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_query-from"); if(res){ hsp_.query_from = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_query-to"); if(res){ hsp_.query_to = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_hit-from"); if(res){ hsp_.hit_from = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_hit-to"); if(res){ hsp_.hit_to = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_query-frame"); if(res){ hsp_.query_frame = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_hit-frame"); if(res){ hsp_.hit_frame = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_identity"); if(res){ hsp_.identity = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_positive"); if(res){ hsp_.positive = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_align-len"); if(res){ hsp_.align_len = atoi(res->GetText()); // cout<<"DEBUG len "<FirstChildElement("Hsp_qseq"); if(res){ hsp_.qseq = res->GetText(); // cout<<"DEBUG len "<FirstChildElement("Hsp_hseq"); if(res){ hsp_.hseq = res->GetText(); // cout<<"DEBUG len "<FirstChildElement("Hsp_midline"); if(res){ hsp_.midline = res->GetText(); // cout<<"DEBUG len "< restraints; set ignore; public: AlmShaper(const Molecules & trg, const Protein & ref, const Blast::Hsp & hsp){ mkhomorest(ref,hsp,trg); } int max_sep(){ int s=0; for(int i=0;is) s = restraints[i].sep; } return s; } BondConst mkconst(const Molecules & mols, int m_sep, double K){ BondConst cst(mols); for(int i=0;im_sep) continue; int a1 = restraints[i].atom1; int a2 = restraints[i].atom2; int f1 = mols.find_fragment(a1); int f2 = mols.find_fragment(a2); if((ignore.find(f1)!=ignore.end())|| (ignore.find(f2)!=ignore.end())){ aout<<">> Ignoring rest: " <<" "<2) addRest(atm1.str(), atm2.str(), ref.distance(ca_1,ca_2), abs(i+q_from-iigap-1-(j+q_from-jjgap-1)), trg); } } } } void addRest(string a1, string a2, double d, int sep, const Molecules & mols){ // cout<<"DEB addinmg "< inline string to_string(const Protein &){ return ""; } template<> inline string to_string(const Molecules &){ return ""; } template<> inline string to_string(const BondConst &){ return ""; } template<> inline string to_string(const AlmShaper &){ return ""; } extern "C" { void init_blast(){ //declarations here Module mod = Module("blast","Interface to ncbi blast"); Class(mod.self(),"hsp"); Class(mod.self(),"blast") .def_method("set_exedir",&Blast::set_exedir) .def_method("exedir",&Blast::exedir) .def_method("set_dbdir",&Blast::set_dbdir) .def_method("dbdir",&Blast::dbdir) .def_method("set_db",&Blast::set_db) .def_method("db",&Blast::db) .def_method("set_pdbdir",&Blast::set_pdbdir) .def_method("pdbdir",&Blast::pdbdir) .def_method("blastpgp",&Blast::blastpgp) .def_method("parse",&Blast::parse) .def_method("extract_sequences",&Blast::extract_sequences) .def_method("hsp",&Blast::hsp) .def_attribute("A",&Blast::A,"Undocumented") .def_attribute("f",&Blast::f,"Undocumented") .def_attribute("e",&Blast::e,"Undocumented") .def_attribute("m",&Blast::m,"Undocumented") .def_attribute("o",&Blast::o,"Undocumented") .def_attribute("y",&Blast::y,"Undocumented") .def_attribute("P",&Blast::P,"Undocumented") .def_attribute("F",&Blast::F,"Undocumented") .def_attribute("G",&Blast::G,"Undocumented") .def_attribute("E",&Blast::E,"Undocumented") .def_attribute("X",&Blast::X,"Undocumented") .def_attribute("N",&Blast::N,"Undocumented") .def_attribute("S",&Blast::S,"Undocumented") .def_attribute("H",&Blast::H,"Undocumented") .def_attribute("a",&Blast::a,"Undocumented") .def_attribute("I",&Blast::I,"Undocumented") .def_attribute("h",&Blast::h,"Undocumented") .def_attribute("c",&Blast::c,"Undocumented") .def_attribute("j",&Blast::j,"Undocumented") .def_attribute("J",&Blast::J,"Undocumented") .def_attribute("Z",&Blast::Z,"Undocumented") .def_attribute("O",&Blast::O,"Undocumented") .def_attribute("M",&Blast::M,"Undocumented") .def_attribute("v",&Blast::v,"Undocumented") .def_attribute("b",&Blast::b,"Undocumented") .def_attribute("C",&Blast::C,"Undocumented") .def_attribute("R",&Blast::R,"Undocumented") .def_attribute("W",&Blast::W,"Undocumented") .def_attribute("z",&Blast::z,"Undocumented") .def_attribute("K",&Blast::K,"Undocumented") .def_attribute("s",&Blast::s,"Undocumented") .def_attribute("Y",&Blast::Y,"Undocumented") .def_attribute("p",&Blast::p,"Undocumented") .def_attribute("k",&Blast::k,"Undocumented") .def_attribute("T",&Blast::T,"Undocumented") .def_attribute("Q",&Blast::Q,"Undocumented") .def_attribute("B",&Blast::B,"Undocumented") .def_attribute("l",&Blast::l,"Undocumented") .def_attribute("U",&Blast::U,"Undocumented") ; Class >(mod.self(),"shaper") .def_method("max_sep",&AlmShaper::max_sep) .def_method("mkconst",&AlmShaper::mkconst) .def_method("add_ignore",&AlmShaper::add_ignore) ; Class >(mod.self(),"psipred") .def_method("run_pass1",&Psipred::run_pass1) .def_method("run_pass2",&Psipred::run_pass2) .def_method("run",&Psipred::run) ; mod.def_function("mkhomorest","",mkhomorest); } }