MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / addDataFile

Method addDataFile

src/openms_gui/source/VISUAL/APPLICATIONS/TOPPViewBase.cpp:515–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513 }
514
515 TOPPViewBase::LOAD_RESULT TOPPViewBase::addDataFile(const String& filename, bool show_options, bool add_to_recent, String caption, UInt window_id, Size spectrum_id)
516 {
517 String abs_filename = File::absolutePath(filename);
518
519 // check if the file exists
520 if (!File::exists(abs_filename))
521 {
522 log_->appendNewHeader(LogWindow::LogState::CRITICAL, "Open file error", String("The file '") + abs_filename + "' does not exist!");
523 return LOAD_RESULT::FILE_NOT_FOUND;
524 }
525
526 // determine file type
527 FileHandler fh;
528 FileTypes::Type file_type = fh.getType(abs_filename);
529 if (file_type == FileTypes::UNKNOWN)
530 {
531 log_->appendNewHeader(LogWindow::LogState::CRITICAL, "Open file error", String("Could not determine file type of '") + abs_filename + "'!");
532 return LOAD_RESULT::FILETYPE_UNKNOWN;
533 }
534
535 // abort if file type unsupported
536 if (!supported_types.contains(file_type))
537 {
538 log_->appendNewHeader(LogWindow::LogState::CRITICAL, "Open file error", String("The type '") + FileTypes::typeToName(file_type) + "' is not supported!");
539 return LOAD_RESULT::FILETYPE_UNSUPPORTED;
540 }
541
542 // try to load data and determine if it's 1D or 2D data
543
544 // create shared pointer to main data types
545 FeatureMapType* feature_map = new FeatureMapType();
546 FeatureMapSharedPtrType feature_map_sptr(feature_map);
547
548 ExperimentSharedPtrType peak_map_sptr(new ExperimentType());
549
550 ConsensusMapType* consensus_map = new ConsensusMapType();
551 ConsensusMapSharedPtrType consensus_map_sptr(consensus_map);
552
553 vector<PeptideIdentification> peptides;
554 // not needed in data but for auto annotation
555 vector<ProteinIdentification> proteins;
556 String annotate_path;
557
558 LayerDataBase::DataType data_type(LayerDataBase::DT_UNKNOWN);
559
560 ODExperimentSharedPtrType on_disc_peaks(new OnDiscMSExperiment);
561
562 // lock the GUI - no interaction possible when loading...
563 GUIHelpers::GUILock glock(this);
564
565 bool cache_ms2_on_disc = (param_.getValue(user_section + "use_cached_ms2") == "true");
566 bool cache_ms1_on_disc = (param_.getValue(user_section + "use_cached_ms1") == "true");
567
568 try
569 {
570 if (file_type == FileTypes::FEATUREXML)
571 {
572 FeatureXMLFile().load(abs_filename, *feature_map);

Callers 1

testGuiMethod · 0.80

Calls 15

appendNewHeaderMethod · 0.80
hasRTMethod · 0.80
swapExtensionMethod · 0.80
setTextMethod · 0.80
getParsingSuccessMethod · 0.80
getMSLevelMethod · 0.80
getChromatogramMethod · 0.80
loadExperimentMethod · 0.80
sortSpectraMethod · 0.80
unlockMethod · 0.80
StringClass · 0.50
getTypeMethod · 0.45

Tested by 1

testGuiMethod · 0.64