[Biophp-dev] Code for the humunguous IO class
Serge Gregorio
biophp-dev@bioinformatics.org
Mon, 28 Apr 2003 14:44:17 +0800
Oops, I forgot to send this with my earlier email. I think
Sean's eFetch etc. code will fall under the category of LIT
parsers and cat-ters (function parse_lit_pubmed() & function
cat_lit_pubmed() the very bottom).
Rgds,
Serge
==================================================================
function autodetect_IO($file, $filetype)
{
// code for autodetecting here, returns an array with two elements, the
// first is the CLASS, and the second element is the IO_FORMAT.
}
function file_verb($filetype, $operation)
{
switch($filetype)
{
case "FILE": return ($operation == "R" ? "parse" : "cat");
case "VAR": return ($operation == "R" ? "eval" : "assign");
case "SQL": return ($operation == "R" ? "select" : "insert");
case "STDIN": return "input";
case "STDOUT": return "output";
}
}
class IO
{
// Constructor function of class IO.
// Sample usage: $oIO = new IO("gbuna.seq", "file", "R", "Xna", "GenBank");
// $oIO = new IO("*", "STDOUT", "W", "Protein", "swp");
function IO($file, $filetype, $operation, $class, $IO_format)
{
$filetype = strtoupper($filetype);
$operation = strtoupper($operation);
$class = strtoupper($class);
$IO_format = strtoupper($IO_format);
if ( (is_null($class)) or (is_null($IO_format)) )
{
$auto_result = autodetect_IO($file, $filetype);
$class = $auto_result[0];
$IO_format = $auto_result[1];
}
elseif ($IO_format == "GENBANK") $IO_format = "GB";
elseif ($IO_format == "SWISSPROT") $IO_format = "SWP";
if (!(in_array($class, array("SEQ", "XNA", "PROTEIN", "RESTEN",
"SEQALIGN", "ENZYME", "PATHWAY"))))
die("ERROR: Invalid value supplied to parameter 'class'!");
$funcname = file_verb($filetype, $operation) . "_" . strtolower($class) . "_" . $IO_format . "()";
eval("$funcname;");
}
// XNA readers/writers =======================================================
// === XNA parsers/cat-ters ==================================================
function parse_xna_gb()
{
}
function cat_xna_gb() {}
// parsers for formats not yet read by GenePHP 2.0
function parse_xna_srs() {}
function cat_xna_srs() {}
// === XNA selectors / insert-ors ==============================================
function select_xna_gphp()
{
}
function insert_xna_gphp()
{
}
// === XNA input-ers / output-ers ==============================================
function input_xna_gb() {}
function output_xna_gb() {}
function input_xna_srs() {}
function output_xna_srs() {}
// Protein readers/writers ====================================================
// === Protein parsers/cat-ters ===============================================
function parse_protein_gb()
{
}
function cat_protein_gb() {}
function parse_protein_swp()
{
}
function cat_protein_swp() {}
function parse_protein_pdb()
{
}
function cat_protein_pdb() {}
// parsers for formats not yet read by GenePHP 2.0
function parse_protein_mmcif() {}
function cat_protein_mmcif() {}
function parse_protein_pir() {}
function cat_protein_pir() {}
// === Protein selectors and insert-ors ========================================
function select_protein_gphp()
{
}
function insert_protein_gphp()
{
}
// === Protein input-er and output-ers ========================================
function input_protein_gb() {}
function output_protein_gb() {}
function input_protein_swp() {}
function output_protein_swp() {}
function input_protein_pdb() {}
function output_protein_pdb() {}
function input_protein_mmcif() {}
function output_protein_mmcif() {}
function input_protein_pir() {}
function output_protein_pir() {}
// SeqAlign readers/writers ====================================================
// === SeqAlign parsers/cat-ers ===============================================
function parse_seqalign_aln()
{
}
function cat_seqalign_aln() {}
// === SeqAlign input-ers / output-ers ==========================================
function input_seqalign_aln() {}
function output_seqalign_aln() {}
// RestEn readers/writers ====================================================
// === RestEn parsers/cat-ers ===============================================
function eval_resten_gphp()
{
}
function assign_resten_gphp()
{
}
// === RestEn selectors/insert-ors =============================================
function select_resten_gphp()
{
}
function insert_resten_gphp()
{
}
// Lit readers/writers =========================================================
// === Lit parsers/cat-ters ====================================================
function parse_lit_pubmed() {}
function cat_lit_pubmed() {}
// === Lit parsers/cat-ters ====================================================
function select_lit_gphp() {}
function insert_lit_gphp() {}
// === Lit input-ers / output-ers ==============================================
function input_lit_pubmed() {}
function output_lit_pubmed() {}
}
Need a new email address that people can remember
Check out the new EudoraMail at
http://www.eudoramail.com