bool open_weights( const char *weight_file, s_motif *motifs[], int num_motifs ) { // open the file ifstream ifs; _CALL( _open_input( ifs, weight_file, ".txt" ) ); // find the EOL character char this_EOL = _find_EOL( ifs ); if( !this_EOL ) // no EOL character was identified { cout << "ERROR: The file has no EOL character." << endl; return false; } // read the file cout << "Reading the weights..." << endl; _CALL( read_weights( ifs, motifs, num_motifs, this_EOL ) ); ifs.close(); return true; }
bool read_FASTA( ifstream &ifs, s_gene *genes[], int *num_genes, char this_EOL ) // reads sequences from &ifs // returns true if successful, false otherwise // // ifs: input file stream // genes: the list of genes whose sequences are to be read // num_genes: will contain the number of genes that are in the list // this_EOL: the end of line character. this character is determined separately in another function for this file stream { // A line cannot be longer than MAX_LINE_LENGTH characters char string[ MAX_LINE_LENGTH + 1 ]; char gene_name[ MAX_LINE_LENGTH + 1 ] = ""; char gene_seq[ MAX_SEQ_LENGTH + 1 ] = ""; // read the file line by line _line_number = 0; // reset the line number while( true ) { // read the line ifs.getline( string, MAX_LINE_LENGTH, this_EOL ); if( !ifs || ifs.eof() ) // the end of the file has reached { // add the last read gene to the list _CALL( _add_gene( gene_name, gene_seq, genes, num_genes ) ); break; } _line_number ++; // update the line number that was just read if( string[ 0 ] == '>' ) // this is a header { // add the last read gene to the list _CALL( _add_gene( gene_name, gene_seq, genes, num_genes ) ); // store the name of the new gene strcpy( gene_name, string + 1 ); gene_seq[ 0 ] = 0; // reset the gene sequence } else // this line contains sequence information strcat( gene_seq, string ); } return true; }
bool open_FASTA( const char *file, s_seq *seqs[], int *num_seqs ) // opens a file and reads its content // returns true if successful, false otherwise // { // open the file ifstream ifs; _CALL( _open_input( ifs, file, ".fasta" ) ); // find the EOL character char this_EOL = _find_EOL( ifs ); if( !this_EOL ) // no EOL character was identified { cout << "ERROR: The file has no EOL character." << endl; return false; } // read the file cout << "Reading the sequences..." << endl; _CALL( read_FASTA( ifs, seqs, num_seqs, this_EOL ) ); // count the number of positive instances int num_pos = 0; int i; for( i = 0; i < *num_seqs; i ++ ) num_pos += seqs[ i ] ->positive; cout << *num_seqs << " sequences were read, including " << num_pos << " positive and " << *num_seqs - num_pos << " negatives." << endl << endl; if( num_pos < 10 || *num_seqs - num_pos < 10 ) { cout << "ERROR: At least 10 positive and 10 negative sequences are required." << endl; return false; } // close the input file stream ifs.close(); return true; }
tree::Exp * X86Frame::externalCall(const std::string &func, const tree::ExpList &args) { Label *flabel = gcnew(Label, (func)); tree::NAME *name = _NAME(flabel); tree::CALL *call = _CALL(name, args); return call; }
bool open_rndforest( const char *file, s_motif *motifs[], int *num_motifs, char const *filter ) // opens a file and reads its content // returns true if successful, false otherwise { // open the file ifstream ifs; _CALL( _open_input( ifs, file, ".txt" ) ); // find the EOL character char this_EOL = _find_EOL( ifs ); if( !this_EOL ) // no EOL character was identified { cout << "ERROR: The file has no EOL character." << endl; return false; } // read the file cout << "Reading RF results..." << endl; _CALL( read_rndforest( ifs, motifs, num_motifs, filter, this_EOL ) ); if( *num_motifs ) cout << *num_motifs << " motifs were read." << endl << endl; else { cout << "ERROR: No motifs were read. The input protein possibly does not have canonical C2H2-ZFs." << endl; return false; } // close the input file stream ifs.close(); return true; }
/// Add a link to another object. virtual STATUS linkObject(OBJECT* from, CSTR& objPath, OBJECT* to) { return _CALL(m_current.dataProvider, linkObject, (from, objPath, to)); }
/// Add a link to another object. virtual STATUS linkObject(CSTR& fullPath, OBJECT* to) { return _CALL(m_current.dataProvider, linkObject, (fullPath, to)); }
/// IDataManagerSvc: Analyze by traversing all data objects in the data store. virtual STATUS traverseTree( AGENT* pAgent ) { return _CALL(m_current.dataManager, traverseTree, (pAgent)); }
/// Find object in the data store. virtual STATUS findObject(OBJECT* parent, int item, OBJECT*& pObject) { return _CALL(m_current.dataProvider, findObject, (parent, item, pObject)); }
/// Update object. virtual STATUS updateObject(OBJECT* parent, CSTR& updatePath) { return _CALL(m_current.dataProvider, updateObject, (parent, updatePath)); }
/// Remove all data objects below the sub tree identified virtual STATUS clearSubTree(CSTR& path) { return _CALL(m_current.dataManager, clearSubTree, (path)); }
/// Unregister object from the data store. virtual STATUS unregisterObject(OBJECT* pObj, CSTR& path) { return _CALL(m_current.dataProvider, unregisterObject, (pObj, path)); }
/// Update object. virtual STATUS updateObject(CSTR& path) { return _CALL(m_current.dataProvider, updateObject, (path)); }
/// Register object with the data store. virtual STATUS registerObject(OBJECT* parent, int obj, OBJECT* pObj) { return _CALL(m_current.dataProvider, registerObject, (parent, obj, pObj)); }
/// Unregister object from the data store. virtual STATUS unregisterObject(CSTR& parent, int obj) { return _CALL(m_current.dataProvider, unregisterObject, (parent, obj)); }
/// Register object with the data store. virtual STATUS registerObject(CSTR& parent, int item, OBJECT* pObj) { return _CALL(m_current.dataProvider, registerObject, (parent, item, pObj)); }
/// Add an item to the preload list virtual STATUS removePreLoadItem(CSTR& item) { return _CALL(m_current.dataProvider, removePreLoadItem, (item)); }
/// Remove an item from the preload list virtual STATUS removePreLoadItem(const DataStoreItem& item) { return _CALL(m_current.dataProvider, removePreLoadItem, (item)); }
/// Remove a link to another object. virtual STATUS unlinkObject(OBJECT* from, CSTR& objPath) { return _CALL(m_current.dataProvider, unlinkObject, (from, objPath)); }
/// Unregister object from the data store. virtual STATUS unregisterObject(OBJECT* pObj, int item ) { return _CALL(m_current.dataProvider, unregisterObject, (pObj, item)); }
/// Update object identified by its directory entry. virtual STATUS updateObject(IRegistry* pDirectory ) { return _CALL(m_current.dataProvider, updateObject, (pDirectory)); }
/// Analyze by traversing all data objects below the sub tree virtual STATUS traverseSubTree(CSTR& path, AGENT* pAgent) { return _CALL(m_current.dataManager, traverseSubTree, (path, pAgent)); }
/// Update object. virtual STATUS updateObject(OBJECT* pObj ) { return _CALL(m_current.dataProvider, updateObject, (pObj)); }
/// IDataManagerSvc: Explore the object store: retrieve the object's parent virtual STATUS objectParent(const IRegistry* pObject, IRegistry*& refpParent) { return _CALL(m_current.dataManager, objectParent, (pObject, refpParent)); }
/// Remove all data objects below the sub tree identified virtual STATUS clearSubTree(OBJECT* pObject) { return _CALL(m_current.dataManager, clearSubTree, (pObject)); }
/// Find object in the data store. virtual STATUS findObject(OBJECT* parent, CSTR& path, OBJECT*& pObject) { return _CALL(m_current.dataProvider, findObject, (parent, path, pObject)); }
/// Retrieve object from data store. virtual STATUS retrieveObject(OBJECT* parent, int item, OBJECT*& pObj ) { return _CALL(m_current.dataProvider, retrieveObject, (parent, item, pObj)); }
/// IDataManagerSvc: Analyze by traversing all data objects below the sub tree virtual STATUS traverseSubTree(OBJECT* pObject, AGENT* pAgent) { return _CALL(m_current.dataManager, traverseSubTree, (pObject, pAgent)); }
/// Find object in the data store. virtual STATUS findObject(CSTR& parent, CSTR& path, OBJECT*& pObj) { return _CALL(m_current.dataProvider, retrieveObject, (parent, path, pObj)); }
/// Explore the object store: retrieve all leaves attached to the object virtual STATUS objectLeaves(const IRegistry* pObject, std::vector<IRegistry*>& leaves) { return _CALL(m_current.dataManager, objectLeaves, (pObject, leaves)); }