bool operator() (const string& rawpath) const
 {
     return bal::to_lower_copy(BFS_STRING(bfs::path(rawpath).extension())) == ".wiff";
 }
Esempio n. 2
0
 bool operator() (const string& rawpath) const
 {
     return bfs::is_directory(rawpath) &&
            bal::to_lower_copy(BFS_STRING(bfs::path(rawpath).extension())) == ".raw";
 }
// TODO: Make this a public function? It's copied and modified from Serializer_mzXML.cpp;
//       instead of returning basename, it returns the full file or directory name.
string translate_SourceFileTypeToRunID(const SourceFile& sf, CVID sourceFileType)
{
    string nameExtension = bal::to_lower_copy(bfs::extension(sf.name));
    string locationExtension = bal::to_lower_copy(bfs::extension(sf.location));
    string result; // MSVC10 is happier with a copy before return?

    switch (sourceFileType)
    {
        // location="file://path/to" name="source.RAW"
        case MS_Thermo_RAW_file:
            if (nameExtension == ".raw")
                return sf.name;
            return "";

        // sane: location="file://path/to/source.raw" name="_FUNC001.DAT"
        // insane: location="file://path/to" name="source.raw"
        case MS_Waters_raw_file:
            if (nameExtension == ".dat" && locationExtension == ".raw")
                return result=BFS_STRING(bfs::path(sf.location).filename());
            else if (nameExtension == ".raw")
                return sf.name;
            return "";

        // location="file://path/to/source.d" name="Analysis.yep"
        case MS_Bruker_Agilent_YEP_file:
            if (nameExtension == ".yep" && locationExtension == ".d")
                return result=BFS_STRING(bfs::path(sf.location).filename());
            return "";
            
        // location="file://path/to/source.d" name="Analysis.baf"
        case MS_Bruker_BAF_file:
            if (nameExtension == ".baf" && locationExtension == ".d")
                return result=BFS_STRING(bfs::path(sf.location).filename());
            return "";

        // location="file://path/to/source.d/AcqData" name="msprofile.bin"
        case MS_Agilent_MassHunter_file:
            if (nameExtension == ".bin" && bfs::path(sf.location).filename() == "AcqData")
                return result=BFS_STRING(bfs::path(sf.location).parent_path().filename());
            return "";

        // location="file://path/to" name="source.mzXML"
        // location="file://path/to" name="source.mz.xml"
        // location="file://path/to" name="source.d" (ambiguous)
        case MS_ISB_mzXML_file:
            if (nameExtension == ".mzxml" || nameExtension == ".d")
                return sf.name;
            else if (bal::iends_with(sf.name, ".mz.xml"))
                return sf.name.substr(0, sf.name.length()-7);
            return "";

        // location="file://path/to" name="source.mzData"
        // location="file://path/to" name="source.mz.data" ???
        case MS_PSI_mzData_file:
            if (nameExtension == ".mzdata")
                return sf.name;
            return "";

        // location="file://path/to" name="source.mgf"
        case MS_Mascot_MGF_file:
            if (nameExtension == ".mgf")
                return sf.name;
            return "";

        // location="file://path/to" name="source.wiff"
        case MS_ABI_WIFF_file:
            if (nameExtension == ".wiff")
                return sf.name;
            return "";

        // location="file://path/to/source/maldi-spot/1/1SRef" name="fid"
        // location="file://path/to/source/1/1SRef" name="fid"
        case MS_Bruker_FID_file:
            return (bfs::path(sf.location) / sf.name).string().substr(7);

        // location="file://path/to/source" name="spectrum-id.t2d"
        // location="file://path/to/source/MS" name="spectrum-id.t2d"
        // location="file://path/to/source/MSMS" name="spectrum-id.t2d"
        case MS_AB_SCIEX_TOF_TOF_T2D_file:
            return (bfs::path(sf.location) / sf.name).string().substr(7);

        default:
            return "";
    }
}