Example #1
0
void HDF5DataWriter::reinit(const Eref & e, ProcPtr p)
{
    steps_ = 0;
    for (unsigned int ii = 0; ii < data_.size(); ++ii){
        H5Dclose(datasets_[ii]);
    }
    data_.clear();
    src_.clear();
    func_.clear();
    datasets_.clear();
    unsigned int numTgt = e.element()->getMsgTargetAndFunctions(e.dataIndex(),
                                                                requestOut(),
                                                                src_,
                                                                func_);
    assert(numTgt ==  src_.size());
    // TODO: what to do when reinit is called? Close the existing file
    // and open a new one in append mode? Or keep adding to the
    // current file?
    if (filename_.empty()){
        filename_ = "moose_data.h5";
    }
    if (filehandle_ > 0 ){
        close();
    }
    if (numTgt == 0){
        return;
    }
    openFile();
    for (unsigned int ii = 0; ii < src_.size(); ++ii){
        string varname = func_[ii];
        size_t found = varname.find("get");
        if (found == 0){
            varname = varname.substr(3);
            if (varname.length() == 0){
                varname = func_[ii];
            } else {
                // TODO: there is no way we can get back the original
                // field-name case. tolower will get the right name in
                // most cases as field names start with lower case by
                // convention in MOOSE.
                varname[0] = tolower(varname[0]);
            }
        }
        assert(varname.length() > 0);
        string path = src_[ii].path() + "/" + varname;
        hid_t dataset_id = getDataset(path);
        datasets_.push_back(dataset_id);
    }
    data_.resize(src_.size());
}
SedimentStructure* SedimentStructureEditorDialog::getSedimentStructure() {
    return (SedimentStructure*) getDataset();
}
LithologicalUnitType* LithologicalUnitTypeEditorDialog::getLithologicalUnitType() {
    return (LithologicalUnitType*) getDataset();
}
CustomSymbol* CustomSymbolEditorDialog::getCustomSymbol() {
    return (CustomSymbol*) getDataset();
}
BedCorrelation* BedCorrelationEditorDialog::getBedCorrelation() {
  return (BedCorrelation*) getDataset();
}
Example #6
0
void procedure(const std::string& input, const std::string& centFile, 
	const std::string& clustersFile, float identity, const char* temp) {

  // Read sequence from input file, one by one
  std::ifstream fileData(input);
  std::string line;
  std::ostringstream dataSeq;
  std::string seqName;

  std::ostringstream oss;
  oss << temp << "/datasetFile.txt";
  std::string dataSetFile = oss.str();
	
  getline(fileData, line);
  dataSeq << line << '\n';
  seqName = line.substr(1, line.size());

  int number;
  bool runFlag = 0;
  bool endFlag = 0;

  int counter = 0;
  double totalTime = 0;
  while(true) {
    if (getline(fileData, line) == 0) {
		runFlag = 1;
		endFlag = 1;
	} else if (line.compare(0, 1, ">") == 0) {
		runFlag = 1;
	}

	if (runFlag) {
        std::cout << seqName << ":\n";
		oss.str("");
		oss << temp << "/seq.fasta";
		std::ofstream myfile(oss.str());
		
		myfile << dataSeq.str();
		myfile.close();

		dataSeq.str("");
		dataSeq.clear();

		clock_t begin = clock();

		// Find potential clusters
		std::vector<std::string> potClusters;

		selectSeq(oss.str(), centFile, potClusters, temp, identity);

		for (std::vector<std::string>::iterator it = potClusters.begin(); 
									it != potClusters.end(); it++) {
	        std::vector<std::string> results;
			number = getDataset(clustersFile, *it, dataSetFile);

			if (number < 2) {
			    std::cout << "  " << *it << "\n";
				results.push_back(*it);

				if (seqName.compare(*it) == 0) {
					counter++;
				}
				continue;
			}
							
			selectSeq(oss.str(), dataSetFile, results, temp, identity);

			for (std::vector<std::string>::iterator it_in = results.begin(); 
									it_in != results.end(); it_in++) {
				std::cout << "  " << *it_in << "\n";
				if (seqName.compare(*it_in) == 0)
					counter++;
			}
		} 

		totalTime += (1.0 * (clock() - begin)) / CLOCKS_PER_SEC;

		if (endFlag) {
			break;
		} else {
			seqName = line.substr(1, line.size());
		}
	}

	runFlag = 0;

	dataSeq << line << '\n';
  }

  std::cout << "Total time: " << totalTime << "\n";
  fileData.close();
  std::cout <<"Correct: " <<counter; 

  return;
}
OutcropQuality* OutcropQualityEditorDialog::getOutcropQuality() {
    return (OutcropQuality*) getDataset();
}
LithologicalUnit* LithologicalUnitEditorDialog::getLithologicalUnit() {
    return (LithologicalUnit*) getDataset();
}
Example #9
0
bool SNIFFER_PDUS_CLASS::getCommandDataset(DCM_COMMAND_CLASS **command_ptr_ptr, DCM_DATASET_CLASS **dataset_ptr_ptr)

//  DESCRIPTION     : Get DICOM command and dataset.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	// initialise return values
	*command_ptr_ptr = NULL;
	*dataset_ptr_ptr = NULL;

	// try to get the DICOM command
	if (getCommand(command_ptr_ptr) == false)
	{
		// failed to decode the DICOM command
		if (loggerM_ptr)
		{
			loggerM_ptr->text(LOG_ERROR, 1, "Failed to import DICOM command");
		}
		return false;
	}

	// check if command field attribute is available
	UINT16 commandField;
	if (!(*command_ptr_ptr)->getUSValue(TAG_COMMAND_FIELD, &commandField))
	{
		// no command field attribute present - can't continue
		if (loggerM_ptr)
		{
			loggerM_ptr->text(LOG_ERROR, 1, "No Command Field (0000,0100) attribute value present in DICOM command");

            // serialize it
            if (serializerM_ptr)
            {
                serializerM_ptr->SerializeReceive(*command_ptr_ptr, NULL);
            }
		}
		return false;
	}

	// check if data set type attribute is available
	UINT16 dataSetType = NO_DATA_SET;
	if (!(*command_ptr_ptr)->getUSValue(TAG_DATA_SET_TYPE, &dataSetType))
	{
		// no data set type attribute present - can't continue
		if (loggerM_ptr)
		{
			loggerM_ptr->text(LOG_ERROR, 1, "No Data Set Type (0000,0800) attribute value present in DICOM command");

            // serialize it
            if (serializerM_ptr)
            {
                serializerM_ptr->SerializeReceive(*command_ptr_ptr, NULL);
            }
		}
		return false;
	}

	// check if SOP Class UID attribute is available - try both affected and requested
	// sop class uids - the command may be validated later to ensuer the correct one defined
	if (!(*command_ptr_ptr)->getUIValue(TAG_AFFECTED_SOP_CLASS_UID, sopClassUidM)) 
	{
		if (!(*command_ptr_ptr)->getUIValue(TAG_REQUESTED_SOP_CLASS_UID, sopClassUidM))
		{
			// SOP Class UID not available
			sopClassUidM = "";
		}
	}

	// check if SOP Instance UID attribute is available - try both affected and requested
	// sop instance uids - the command may be validated later to ensure the correct one defined
	if (!(*command_ptr_ptr)->getUIValue(TAG_AFFECTED_SOP_INSTANCE_UID, sopInstanceUidM)) 
	{
		if (!(*command_ptr_ptr)->getUIValue(TAG_REQUESTED_SOP_INSTANCE_UID, sopInstanceUidM))
		{
			// SOP Instance UID not available
			sopInstanceUidM = "";
		}
	}

	// check if a dataset is present
	if (dataSetType != NO_DATA_SET)
	{
		// try to decode dataset
		if (getDataset(dataset_ptr_ptr) == false)
		{
			// failed to decode the DICOM dataset
			if (loggerM_ptr)
			{
				loggerM_ptr->text(LOG_ERROR, 1, "Failed to import DICOM dataset");
			}
			return false;
		}
	}

	// return result
	return true;
}