Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
 /// Add a link to another object.
 virtual STATUS linkObject(OBJECT* from, CSTR& objPath, OBJECT* to)  {
   return _CALL(m_current.dataProvider, linkObject, (from, objPath, to));
 }
Ejemplo n.º 7
0
 /// Add a link to another object.
 virtual STATUS linkObject(CSTR& fullPath, OBJECT* to)  {
   return _CALL(m_current.dataProvider, linkObject, (fullPath, to));
 }
Ejemplo n.º 8
0
 /// IDataManagerSvc: Analyze by traversing all data objects in the data store.
 virtual STATUS traverseTree( AGENT* pAgent )  {
   return _CALL(m_current.dataManager, traverseTree, (pAgent));
 }
Ejemplo n.º 9
0
 /// Find object in the data store.
 virtual STATUS findObject(OBJECT* parent, int item, OBJECT*& pObject)  {
   return _CALL(m_current.dataProvider, findObject, (parent, item, pObject));
 }
Ejemplo n.º 10
0
 /// Update object.
 virtual STATUS updateObject(OBJECT* parent, CSTR& updatePath)  {
   return _CALL(m_current.dataProvider, updateObject, (parent, updatePath));
 }
Ejemplo n.º 11
0
 /// Remove all data objects below the sub tree identified
 virtual STATUS clearSubTree(CSTR& path)  {
   return _CALL(m_current.dataManager, clearSubTree, (path));
 }
Ejemplo n.º 12
0
 /// Unregister object from the data store.
 virtual STATUS unregisterObject(OBJECT* pObj, CSTR& path)  {
   return _CALL(m_current.dataProvider, unregisterObject, (pObj, path));
 }
Ejemplo n.º 13
0
 /// Update object.
 virtual STATUS updateObject(CSTR& path)  {
   return _CALL(m_current.dataProvider, updateObject, (path));
 }
Ejemplo n.º 14
0
 /// Register object with the data store.
 virtual STATUS registerObject(OBJECT* parent, int obj, OBJECT* pObj)  {
   return _CALL(m_current.dataProvider, registerObject, (parent, obj, pObj));
 }
Ejemplo n.º 15
0
 /// Unregister object from the data store.
 virtual STATUS unregisterObject(CSTR& parent, int obj)  {
   return _CALL(m_current.dataProvider, unregisterObject, (parent, obj));
 }
Ejemplo n.º 16
0
 /// Register object with the data store.
 virtual STATUS registerObject(CSTR& parent, int item, OBJECT* pObj)  {
   return _CALL(m_current.dataProvider, registerObject, (parent, item, pObj));
 }
Ejemplo n.º 17
0
 /// Add an item to the preload list
 virtual STATUS removePreLoadItem(CSTR& item)  {
   return _CALL(m_current.dataProvider, removePreLoadItem, (item));
 }
Ejemplo n.º 18
0
 /// Remove an item from the preload list
 virtual STATUS removePreLoadItem(const DataStoreItem& item)  {
   return _CALL(m_current.dataProvider, removePreLoadItem, (item));
 }
Ejemplo n.º 19
0
 /// Remove a link to another object.
 virtual STATUS unlinkObject(OBJECT* from, CSTR& objPath)  {
   return _CALL(m_current.dataProvider, unlinkObject, (from, objPath));
 }
Ejemplo n.º 20
0
 /// Unregister object from the data store.
 virtual STATUS unregisterObject(OBJECT* pObj, int item )  {
   return _CALL(m_current.dataProvider, unregisterObject, (pObj, item));
 }
Ejemplo n.º 21
0
 /// Update object identified by its directory entry.
 virtual STATUS updateObject(IRegistry* pDirectory )  {
   return _CALL(m_current.dataProvider, updateObject, (pDirectory));
 }
Ejemplo n.º 22
0
 /// 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));
 }
Ejemplo n.º 23
0
 /// Update object.
 virtual STATUS updateObject(OBJECT* pObj )  {
   return _CALL(m_current.dataProvider, updateObject, (pObj));
 }
Ejemplo n.º 24
0
 /// 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));
 }
Ejemplo n.º 25
0
 /// Remove all data objects below the sub tree identified
 virtual STATUS clearSubTree(OBJECT* pObject)  {
   return _CALL(m_current.dataManager, clearSubTree, (pObject));
 }
Ejemplo n.º 26
0
 /// Find object in the data store.
 virtual STATUS findObject(OBJECT* parent, CSTR& path, OBJECT*& pObject)  {
   return _CALL(m_current.dataProvider, findObject, (parent, path, pObject));
 }
Ejemplo n.º 27
0
 /// Retrieve object from data store.
 virtual STATUS retrieveObject(OBJECT* parent, int item, OBJECT*& pObj )  {
   return _CALL(m_current.dataProvider, retrieveObject, (parent, item, pObj));
 }
Ejemplo n.º 28
0
 /// 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));
 }
Ejemplo n.º 29
0
 /// Find object in the data store.
 virtual STATUS findObject(CSTR& parent, CSTR& path, OBJECT*& pObj)  {
   return _CALL(m_current.dataProvider, retrieveObject, (parent, path, pObj));
 }
Ejemplo n.º 30
0
 /// 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));
 }