void SamFormatParser::ParseRGLine(const string& line) { SamReadGroup rg; // split string into tokens vector<string> tokens = Split(line, Constants::SAM_TAB); // iterate over tokens vector<string>::const_iterator tokenIter = tokens.begin(); vector<string>::const_iterator tokenEnd = tokens.end(); for ( ; tokenIter != tokenEnd; ++tokenIter ) { // get token tag/value const string tokenTag = (*tokenIter).substr(0,2); const string tokenValue = (*tokenIter).substr(3); // set read group contents if ( tokenTag == Constants::SAM_RG_ID_TAG ) rg.ID = tokenValue; else if ( tokenTag == Constants::SAM_RG_SAMPLE_TAG ) rg.Sample = tokenValue; else if ( tokenTag == Constants::SAM_RG_LIBRARY_TAG ) rg.Library = tokenValue; else if ( tokenTag == Constants::SAM_RG_DESCRIPTION_TAG ) rg.Description = tokenValue; else if ( tokenTag == Constants::SAM_RG_PLATFORMUNIT_TAG ) rg.PlatformUnit = tokenValue; else if ( tokenTag == Constants::SAM_RG_PREDICTEDINSERTSIZE_TAG ) rg.PredictedInsertSize = tokenValue; else if ( tokenTag == Constants::SAM_RG_SEQCENTER_TAG ) rg.SequencingCenter = tokenValue; else if ( tokenTag == Constants::SAM_RG_PRODUCTIONDATE_TAG ) rg.ProductionDate = tokenValue; else if ( tokenTag == Constants::SAM_RG_SEQTECHNOLOGY_TAG ) rg.SequencingTechnology = tokenValue; else cerr << "SamFormatParser ERROR: unknown RG tag: " << tokenTag << endl; } // if @RG line exists, ID must be provided if ( !rg.HasID() ) { cerr << "SamFormatParser ERROR: @RG line is missing ID tag" << endl; return; } // if @RG line exists, SM must be provided if ( !rg.HasSample() ) { cerr << "SamFormatParser ERROR: @RG line is missing SM tag" << endl; return; } // store SAM read group entry m_header.ReadGroups.Add(rg); }
void SamFormatParser::ParseRGLine(const string& line) { SamReadGroup rg; // split string into tokens vector<string> tokens = Split(line, Constants::SAM_TAB); // iterate over tokens vector<string>::const_iterator tokenIter = tokens.begin(); vector<string>::const_iterator tokenEnd = tokens.end(); for ( ; tokenIter != tokenEnd; ++tokenIter ) { // get token tag/value const string tokenTag = (*tokenIter).substr(0,2); const string tokenValue = (*tokenIter).substr(3); // set read group contents if ( tokenTag == Constants::SAM_RG_ID_TAG ) rg.ID = tokenValue; else if ( tokenTag == Constants::SAM_RG_DESCRIPTION_TAG ) rg.Description = tokenValue; else if ( tokenTag == Constants::SAM_RG_FLOWORDER_TAG ) rg.FlowOrder = tokenValue; else if ( tokenTag == Constants::SAM_RG_KEYSEQUENCE_TAG ) rg.KeySequence = tokenValue; else if ( tokenTag == Constants::SAM_RG_LIBRARY_TAG ) rg.Library = tokenValue; else if ( tokenTag == Constants::SAM_RG_PLATFORMUNIT_TAG ) rg.PlatformUnit = tokenValue; else if ( tokenTag == Constants::SAM_RG_PREDICTEDINSERTSIZE_TAG ) rg.PredictedInsertSize = tokenValue; else if ( tokenTag == Constants::SAM_RG_PRODUCTIONDATE_TAG ) rg.ProductionDate = tokenValue; else if ( tokenTag == Constants::SAM_RG_PROGRAM_TAG ) rg.Program = tokenValue; else if ( tokenTag == Constants::SAM_RG_SAMPLE_TAG ) rg.Sample = tokenValue; else if ( tokenTag == Constants::SAM_RG_SEQCENTER_TAG ) rg.SequencingCenter = tokenValue; else if ( tokenTag == Constants::SAM_RG_SEQTECHNOLOGY_TAG ) rg.SequencingTechnology = tokenValue; else { // custom tag CustomHeaderTag otherTag; otherTag.TagName = tokenTag; otherTag.TagValue = tokenValue; rg.CustomTags.push_back(otherTag); } } // check for required tags if ( !rg.HasID() ) throw BamException("SamFormatParser::ParseRGLine", "@RG line is missing ID tag"); // store SAM read group entry m_header.ReadGroups.Add(rg); }