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; }
MYI_STRUCT *_fancy_open_input(NFN_STRUCT *ESI, FILE_LISTS *ECX) { // ESI is NFN_STRUCT containing raw filename // ECX is list of paths if (!_open_input(ESI, &OBJ_DEVICE)) return OBJ_DEVICE; // Well, it would have been nice if (ESI->NFN_FLAGS & NFN_PATH_SPECIFIED) goto FANCY_FAIL; FILE_LIST_STRUCT *EDI = ECX->FILE_FIRST_GINDEX; goto TEST_PATH; PATH_LOOP: if (EDI->FILE_LIST_NFN.NFN_FLAGS & NFN_PATH_SPECIFIED) // skip 'NUL' { // Need to move just path if (!_open_input(_move_ecxpath_eax(ESI, &EDI->FILE_LIST_NFN), &OBJ_DEVICE)) { FILE_LIST_STRUCT *EDX = CURN_FILE_LIST_GINDEX; if (EDX) EDX->FILE_LIST_PATH_GINDEX = EDI; return OBJ_DEVICE; } } // Try next path TEST_PATH: EDI = EDI->FILE_LIST_NEXT_GINDEX; if (EDI) goto PATH_LOOP; FANCY_FAIL: _delete_phantom_path(ESI); return 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; }
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; }