/************************************************************************\ * * * NAME: * * alphlist.cc * * * * PURPOSE: * * List all available alphabets from Alphabet.[cc,h] * * * * FUNCTIONS: * * * * HISTORY: * * Richard Hughey rph@ce.ucsc.edu * * 21 July 1994 * * * \************************************************************************/ #include "Alphabet.h" #include "FeatureRangeAlphabet.h" #include "FeatureCenterAlphabet.h" #include "MultiFeatureAlphabet.h" #include "Alph.h" #include class DNANAlphabet : public DNAAlphabet { public: enum {N = 20}; DNANAlphabet (void) : DNAAlphabet("DNA_NN") { reset_name ("DNA_N"); add_all_match ('N'); } }; void print_is_valid_char_test(const Alphabet *a, const char c) { cerr << a->name() << "->is_valid_char(" << c << "): " << a->is_valid_char(c) << "\n"; } void print_short_name_to_base_test(const Alphabet *a) { cerr << "Short name to base test for Alphabet: " << a->name() << "\n"; int bi; for (bi = 0; bi < a->norm_wc_length(); bi ++) { Base b = a->unindex(bi); char ch = a->to_char(b); const char *short_name = a->abbrev(b); if (short_name != NULL) { Base short_name_base = a->to_base(short_name); char short_name_char = a->to_char(short_name_base); cerr << "index: " << bi << " char: " << ch << " short_name: " << short_name << " short_name_char: " << short_name_char << " short_name_ptr: " << static_cast(short_name) << "\n"; } else { cerr << "index: " << bi << " char: " << ch << " short_name: none" << " short_name_ptr: " << static_cast(short_name) << "\n"; } } } int main (int argc, char **argv) { // force NucleicAlphabet to exist: Alph::RNA(); // force ExtAminoAlphabet to exist: Alph::ExtAA(); // Make sure FeatureRangeAlphabet is linked in assert(FeatureRangeAlphabet::classID()); assert(FeatureCenterAlphabet::classID()); assert(MultiFeatureAlphabet::classID()); Alphabet::set_default ("RNA"); DNANAlphabet DNA_N; assert (Alph::ret_default()->id() == Alph::RNA().id()); ifstream DSSP_in(DSSP_ALPHABET_LIB); Alphabet *DSSP = dynamic_cast(NamedClass::read_new(DSSP_in)); // read all the alphabets in that file while (NamedClass::read_new(DSSP_in)) {} ifstream pdb_atoms_in(PDB_ATOMS_ALPHABET_LIB); Alphabet *pdb_atoms = dynamic_cast(NamedClass::read_new(pdb_atoms_in)); ifstream zeta_in(ZETA_ALPHABET_LIB); Alphabet *zeta = dynamic_cast(NamedClass::read_new(zeta_in)); ifstream phi_zeta_in(PHI_ZETA_ALPHABET_LIB); Alphabet *phi_zeta = dynamic_cast(NamedClass::read_new(phi_zeta_in)); ifstream bys_in(BYS_ALPHABET_LIB); Alphabet *bys = dynamic_cast(NamedClass::read_new(bys_in)); Base::limits(cout); cout << "------------------------------------------------------------------\n"; Alphabet::describe_all(cout); ofstream DSSP_out("DSSP.write.alphabet"); DSSP->write(DSSP_out); ofstream zeta_out("zeta.write.alphabet"); zeta->write(zeta_out); ofstream phi_zeta_out("phi_zeta.write.alphabet"); phi_zeta->write(phi_zeta_out); ofstream bys_out("bys.write.alphabet"); bys->write(bys_out); ofstream std_alphabet_out("std.alphabet"); Alph::Nucleic().write(std_alphabet_out); std_alphabet_out << "\n\n\n"; Alph::RNA().write(std_alphabet_out); std_alphabet_out << "\n\n\n"; Alph::DNA().write(std_alphabet_out); std_alphabet_out << "\n\n\n"; Alph::ExtDNA().write(std_alphabet_out); std_alphabet_out << "\n\n\n"; Alph::AA().write(std_alphabet_out); std_alphabet_out << "\n\n\n"; Alph::ExtAA().write(std_alphabet_out); std_alphabet_out.close(); /*************************************************** ifstream ExtDNA_in("ExtDNA.write.alphabet"); Alphabet *ExtDNA_reread = (Alphabet *)NamedClass::read_new(ExtDNA_in); cerr << "main: ExtDNA_reread->type()->name(): " << ExtDNA_reread->type()->name() << "\n"; ofstream ExtDNA_rewrite_out("ExtDNA.rewrite.alphabet"); ExtDNA_reread->write(ExtDNA_rewrite_out); ****************************************************/ /*********************************************** ifstream BadExtAA_in("BadExtAA.alphabet"); Alphabet *BadExtAA = (Alphabet *)NamedClass::read_new(BadExtAA_in); ************************************************/ // print_short_name_to_base_test(&Alph::ExtAA()); delete DSSP; delete zeta; delete pdb_atoms; Base b1, b2; b1 = Base::null(); b2 = b1; assert (b2.no_wc_match (b1, NULL_NULL_TRUE)); assert ( (b1 = Alph::RNA().to_base ('-')).is_null()); // cout << "Enter bases in the default alphabet " << // Alph::ret_default ()->name() << endl; // while (cin >> b1) cout << b1; return 0; } // CHANGE LOG: // 30 March 2004 Kevin Karplus // fixed old-style casts // Wed Jun 29 11:38:43 PDT 2005 Kevin Karplus // Added macros for filenames, so that the Makefile has the only // place for the directories // Fri Aug 14 12:52:05 PDT 2009 Kevin Karplus // Added test of FeatureRangeAlphabet (zeta) // Wed Aug 19 14:20:41 PDT 2009 Kevin Karplus // Added test of MultiRangeAlphabet // Sat Aug 22 12:13:28 PDT 2009 Kevin Karplus // Added test of FeatureCenterAlphabet