// merge all channels into the first one // no further influence of the simulation process needed void LabelFreeLabeler::setUpHook(SimTypes::FeatureMapSimVector& features) { if (features.size() == 1) return; else { LOG_INFO << "Merging input FASTA files into one. Intensities will be summed up if duplicates occur."; SimTypes::FeatureMapSim final_map = mergeProteinIdentificationsMaps_(features); features.clear(); features.push_back(final_map); } }
void SILACLabeler::postDigestHook(SimTypes::FeatureMapSimVector& features_to_simulate) { SimTypes::FeatureMapSim& light_channel_features = features_to_simulate[0]; SimTypes::FeatureMapSim& medium_channel_features = features_to_simulate[1]; // merge the generated feature maps and create consensus SimTypes::FeatureMapSim final_feature_map = mergeProteinIdentificationsMaps_(features_to_simulate); if (features_to_simulate.size() == 2) { Map<String, Feature> unlabeled_features_index; for (SimTypes::FeatureMapSim::iterator unlabeled_features_iter = light_channel_features.begin(); unlabeled_features_iter != light_channel_features.end(); ++unlabeled_features_iter) { (*unlabeled_features_iter).ensureUniqueId(); unlabeled_features_index.insert(std::make_pair( (*unlabeled_features_iter).getPeptideIdentifications()[0].getHits()[0].getSequence().toString() , *unlabeled_features_iter )); } // iterate over second map for (SimTypes::FeatureMapSim::iterator labeled_feature_iter = medium_channel_features.begin(); labeled_feature_iter != medium_channel_features.end(); ++labeled_feature_iter) { const String unmodified_sequence = getUnmodifiedSequence_(*labeled_feature_iter, medium_channel_arginine_label_, medium_channel_lysine_label_); // guarantee uniqueness (*labeled_feature_iter).ensureUniqueId(); // check if we have a pair if (unlabeled_features_index.has(unmodified_sequence)) { // own scope as we don't know what happens to 'f_modified' once we call erase() below Feature& unlabeled_feature = unlabeled_features_index[unmodified_sequence]; // guarantee uniqueness unlabeled_feature.ensureUniqueId(); // feature has a SILAC Label and is not equal to non-labeled if ((*labeled_feature_iter).getPeptideIdentifications()[0].getHits()[0].getSequence().isModified()) { // add features to final map final_feature_map.push_back(*labeled_feature_iter); final_feature_map.push_back(unlabeled_feature); // create consensus feature ConsensusFeature cf; cf.insert(MEDIUM_FEATURE_MAPID_, *labeled_feature_iter); cf.insert(LIGHT_FEATURE_MAPID_, unlabeled_feature); cf.ensureUniqueId(); consensus_.push_back(cf); // remove unlabeled feature unlabeled_features_index.erase(unmodified_sequence); } else { // merge features since they are equal Feature final_feature = mergeFeatures_(*labeled_feature_iter, unmodified_sequence, unlabeled_features_index, 1, 2); final_feature_map.push_back(final_feature); } } else // no SILAC pair, just add the labeled one { final_feature_map.push_back(*labeled_feature_iter); } } // add singletons from unlabeled channel // clean up unlabeled_index for (Map<String, Feature>::iterator unlabeled_index_iter = unlabeled_features_index.begin(); unlabeled_index_iter != unlabeled_features_index.end(); ++unlabeled_index_iter) { // the single ones from c0 final_feature_map.push_back(unlabeled_index_iter->second); } } // merge three channels if (features_to_simulate.size() == 3) { // index of unlabeled channelunlabeled_feature Map<String, Feature> unlabeled_features_index; for (SimTypes::FeatureMapSim::iterator unlabeled_features_iter = light_channel_features.begin(); unlabeled_features_iter != light_channel_features.end(); ++unlabeled_features_iter) { (*unlabeled_features_iter).ensureUniqueId(); unlabeled_features_index.insert(std::make_pair( (*unlabeled_features_iter).getPeptideIdentifications()[0].getHits()[0].getSequence().toString() , *unlabeled_features_iter )); } // index of labeled channel Map<String, Feature> medium_features_index; for (SimTypes::FeatureMapSim::iterator labeled_features_iter = medium_channel_features.begin(); labeled_features_iter != medium_channel_features.end(); ++labeled_features_iter) { (*labeled_features_iter).ensureUniqueId(); medium_features_index.insert(std::make_pair( getUnmodifiedSequence_(*labeled_features_iter, medium_channel_arginine_label_, medium_channel_lysine_label_) , *labeled_features_iter )); } SimTypes::FeatureMapSim& heavy_labeled_features = features_to_simulate[2]; for (SimTypes::FeatureMapSim::iterator heavy_labeled_feature_iter = heavy_labeled_features.begin(); heavy_labeled_feature_iter != heavy_labeled_features.end(); ++heavy_labeled_feature_iter) { Feature& heavy_feature = *heavy_labeled_feature_iter; heavy_feature.ensureUniqueId(); String heavy_feature_unmodified_sequence = getUnmodifiedSequence_(heavy_feature, heavy_channel_arginine_label_, heavy_channel_lysine_label_); if (unlabeled_features_index.has(heavy_feature_unmodified_sequence) && medium_features_index.has(heavy_feature_unmodified_sequence)) { // it is a triplet // c2 & c1 modified if (heavy_feature_unmodified_sequence != heavy_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().toString()) { // add features to final map final_feature_map.push_back(heavy_feature); final_feature_map.push_back(medium_features_index[heavy_feature_unmodified_sequence]); final_feature_map.push_back(unlabeled_features_index[heavy_feature_unmodified_sequence]); ConsensusFeature c_triplet; c_triplet.insert(HEAVY_FEATURE_MAPID_, heavy_feature); c_triplet.insert(LIGHT_FEATURE_MAPID_, unlabeled_features_index[heavy_feature_unmodified_sequence]); c_triplet.insert(MEDIUM_FEATURE_MAPID_, medium_features_index[heavy_feature_unmodified_sequence]); c_triplet.ensureUniqueId(); consensus_.push_back(c_triplet); } else { // merge all three channels Feature completeMerge = mergeAllChannelFeatures_(heavy_feature, heavy_feature_unmodified_sequence, unlabeled_features_index, medium_features_index); final_feature_map.push_back(completeMerge); } // remove features from indices unlabeled_features_index.erase(heavy_feature_unmodified_sequence); medium_features_index.erase(heavy_feature_unmodified_sequence); } else if (unlabeled_features_index.has(heavy_feature_unmodified_sequence)) { // 2nd case light and heavy pair if (heavy_feature_unmodified_sequence != heavy_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().toString()) { // add features to final map final_feature_map.push_back(heavy_feature); final_feature_map.push_back(unlabeled_features_index[heavy_feature_unmodified_sequence]); ConsensusFeature c_duplet; c_duplet.insert(HEAVY_FEATURE_MAPID_, heavy_feature); c_duplet.insert(LIGHT_FEATURE_MAPID_, unlabeled_features_index[heavy_feature_unmodified_sequence]); c_duplet.ensureUniqueId(); consensus_.push_back(c_duplet); } else { // merge all three channels Feature completeMerge = mergeFeatures_(heavy_feature, heavy_feature_unmodified_sequence, unlabeled_features_index, 1, 3); final_feature_map.push_back(completeMerge); } // remove features from indices unlabeled_features_index.erase(heavy_feature_unmodified_sequence); } else if (medium_features_index.has(heavy_feature_unmodified_sequence)) { // 3rd case medium and heavy pair if (heavy_feature_unmodified_sequence != heavy_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().toString()) { // add features to final map final_feature_map.push_back(heavy_feature); final_feature_map.push_back(medium_features_index[heavy_feature_unmodified_sequence]); ConsensusFeature c_duplet; c_duplet.insert(HEAVY_FEATURE_MAPID_, heavy_feature); c_duplet.insert(MEDIUM_FEATURE_MAPID_, medium_features_index[heavy_feature_unmodified_sequence]); c_duplet.ensureUniqueId(); consensus_.push_back(c_duplet); } else { // merge all Feature completeMerge = mergeFeatures_(heavy_feature, heavy_feature_unmodified_sequence, medium_features_index, 2, 3); final_feature_map.push_back(completeMerge); } // remove features from indices medium_features_index.erase(heavy_feature_unmodified_sequence); } else { // heavy feature is a singleton final_feature_map.push_back(heavy_feature); } } // clean up labeled_index for (Map<String, Feature>::iterator medium_channle_index_iterator = medium_features_index.begin(); medium_channle_index_iterator != medium_features_index.end(); ++medium_channle_index_iterator) { Feature& medium_channel_feature = medium_channle_index_iterator->second; medium_channel_feature.ensureUniqueId(); String medium_channel_feature_unmodified_sequence = getUnmodifiedSequence_(medium_channel_feature, medium_channel_arginine_label_, medium_channel_lysine_label_); if (unlabeled_features_index.has(medium_channel_feature_unmodified_sequence)) { // 1. case: pair between c0 and c1 if (medium_channel_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().isModified()) { // add features to final map final_feature_map.push_back(medium_channel_feature); final_feature_map.push_back(unlabeled_features_index[medium_channel_feature_unmodified_sequence]); ConsensusFeature c_duplet; c_duplet.insert(MEDIUM_FEATURE_MAPID_, medium_channel_feature); c_duplet.insert(LIGHT_FEATURE_MAPID_, unlabeled_features_index[medium_channel_feature_unmodified_sequence]); c_duplet.ensureUniqueId(); consensus_.push_back(c_duplet); } else { // merge Feature completeMerge = mergeFeatures_(medium_channel_feature, medium_channel_feature_unmodified_sequence, unlabeled_features_index, 1, 2); final_feature_map.push_back(completeMerge); } // remove features from indices unlabeled_features_index.erase(medium_channel_feature_unmodified_sequence); } else { // c1 is alone final_feature_map.push_back(medium_channel_feature); } } // clean up unlabeled_index for (Map<String, Feature>::iterator unlabeled_index_iter = unlabeled_features_index.begin(); unlabeled_index_iter != unlabeled_features_index.end(); ++unlabeled_index_iter) { // the single ones from c0 final_feature_map.push_back(unlabeled_index_iter->second); } } features_to_simulate.clear(); features_to_simulate.push_back(final_feature_map); consensus_.setProteinIdentifications(final_feature_map.getProteinIdentifications()); ConsensusMap::FileDescription map_description; map_description.label = "Simulation (Labeling Consensus)"; map_description.size = features_to_simulate.size(); consensus_.getFileDescriptions()[0] = map_description; }
void ICPLLabeler::postDigestHook(SimTypes::FeatureMapSimVector& features_to_simulate) { SimTypes::FeatureMapSim& light_labeled_features = features_to_simulate[0]; SimTypes::FeatureMapSim& medium_labeled_features = features_to_simulate[1]; if (param_.getValue("label_proteins") == "false") // loop for peptide-labeling (post-digest-labeling) { // iterate over first map for light labeling for (SimTypes::FeatureMapSim::iterator lf_iter = light_labeled_features.begin(); lf_iter != light_labeled_features.end(); ++lf_iter) { lf_iter->ensureUniqueId(); addModificationToPeptideHit_(*lf_iter, light_channel_label_); } // iterate over second map for medium labeling for (SimTypes::FeatureMapSim::iterator lf_iter = medium_labeled_features.begin(); lf_iter != medium_labeled_features.end(); ++lf_iter) { lf_iter->ensureUniqueId(); addModificationToPeptideHit_(*lf_iter, medium_channel_label_); } if (features_to_simulate.size() == 3) //third channel labeling can only be done, if a third channel exist { SimTypes::FeatureMapSim& heavy_labeled_features = features_to_simulate[2]; // iterate over third map for (SimTypes::FeatureMapSim::iterator lf_iter = heavy_labeled_features.begin(); lf_iter != heavy_labeled_features.end(); ++lf_iter) { lf_iter->ensureUniqueId(); addModificationToPeptideHit_(*lf_iter, heavy_channel_label_); } } } // merge the generated feature maps and create consensus SimTypes::FeatureMapSim final_feature_map = mergeProteinIdentificationsMaps_(features_to_simulate); if (features_to_simulate.size() == 2) // merge_modus for two FeatureMaps { // create index of light channel features for easy mapping of medium-to-light channel Map<String, Feature> light_labeled_features_index; for (SimTypes::FeatureMapSim::iterator light_labeled_features_iter = light_labeled_features.begin(); light_labeled_features_iter != light_labeled_features.end(); ++light_labeled_features_iter) { (*light_labeled_features_iter).ensureUniqueId(); light_labeled_features_index.insert(std::make_pair( getUnmodifiedAASequence_((*light_labeled_features_iter), light_channel_label_), *light_labeled_features_iter )); } // iterate over second map for (SimTypes::FeatureMapSim::iterator medium_labeled_feature_iter = medium_labeled_features.begin(); medium_labeled_feature_iter != medium_labeled_features.end(); ++medium_labeled_feature_iter) { AASequence medium_labeled_feature_sequence = (*medium_labeled_feature_iter).getPeptideIdentifications()[0].getHits()[0].getSequence(); // guarantee uniqueness (*medium_labeled_feature_iter).ensureUniqueId(); // check if we have a pair if (light_labeled_features_index.has(getUnmodifiedAASequence_((*medium_labeled_feature_iter), medium_channel_label_))) { // own scope as we don't know what happens to 'f_modified' once we call erase() below Feature& light_labeled_feature = light_labeled_features_index[getUnmodifiedAASequence_((*medium_labeled_feature_iter), medium_channel_label_)]; // guarantee uniqueness light_labeled_feature.ensureUniqueId(); if (medium_labeled_feature_sequence.isModified()) // feature has a medium ICPL-Label and is not equal to light-labeled { // add features to final map final_feature_map.push_back(*medium_labeled_feature_iter); final_feature_map.push_back(light_labeled_feature); // create consensus feature ConsensusFeature cf; cf.insert(MEDIUM_FEATURE_MAPID_, *medium_labeled_feature_iter); cf.insert(LIGHT_FEATURE_MAPID_, light_labeled_feature); consensus_.push_back(cf); // remove light-labeled feature light_labeled_features_index.erase(getUnmodifiedAASequence_((*medium_labeled_feature_iter), medium_channel_label_)); } else { // merge features since they are equal Feature final_feature = mergeFeatures_(*medium_labeled_feature_iter, medium_labeled_feature_sequence, light_labeled_features_index); final_feature_map.push_back(final_feature); } } else // no ICPL pair, just add the medium-labeled one { final_feature_map.push_back(*medium_labeled_feature_iter); } } // add singletons from light-labeled channel // clean up light-labeled_index for (Map<String, Feature>::iterator light_labeled_index_iter = light_labeled_features_index.begin(); light_labeled_index_iter != light_labeled_features_index.end(); ++light_labeled_index_iter) { // the single ones from c0 final_feature_map.push_back(light_labeled_index_iter->second); } } else if (features_to_simulate.size() == 3) // merge_modus for three Channels { // create index of light channel features for easy mapping of heavy-to-medium-to-light channel Map<String, Feature> light_labeled_features_index; for (SimTypes::FeatureMapSim::iterator light_labeled_features_iter = light_labeled_features.begin(); light_labeled_features_iter != light_labeled_features.end(); ++light_labeled_features_iter) { (*light_labeled_features_iter).ensureUniqueId(); light_labeled_features_index.insert(std::make_pair( getUnmodifiedAASequence_(*light_labeled_features_iter, light_channel_label_), *light_labeled_features_iter )); } // create index of medium channel features for easy mapping of heavy-to-medium-to-light channel Map<String, Feature> medium_labeled_features_index; for (SimTypes::FeatureMapSim::iterator medium_labeled_features_iter = medium_labeled_features.begin(); medium_labeled_features_iter != medium_labeled_features.end(); ++medium_labeled_features_iter) { (*medium_labeled_features_iter).ensureUniqueId(); medium_labeled_features_index.insert(std::make_pair( getUnmodifiedAASequence_((*medium_labeled_features_iter), medium_channel_label_), *medium_labeled_features_iter )); } for (SimTypes::FeatureMapSim::iterator heavy_labeled_feature_iter = features_to_simulate[2].begin(); heavy_labeled_feature_iter != features_to_simulate[2].end(); ++heavy_labeled_feature_iter) { Feature& heavy_feature = *heavy_labeled_feature_iter; String heavy_feature_unmodified_sequence = getUnmodifiedAASequence_(heavy_feature, heavy_channel_label_); heavy_feature.ensureUniqueId(); if (light_labeled_features_index.has(heavy_feature_unmodified_sequence) && medium_labeled_features_index.has(heavy_feature_unmodified_sequence)) { // 1st case .. it is a triplet if (heavy_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().isModified()) { // if heavy feature is modified, all light and medium channel are also // add features to final map final_feature_map.push_back(heavy_feature); final_feature_map.push_back(medium_labeled_features_index[heavy_feature_unmodified_sequence]); final_feature_map.push_back(light_labeled_features_index[heavy_feature_unmodified_sequence]); // create triplet consensus feature ConsensusFeature c_triplet; c_triplet.insert(HEAVY_FEATURE_MAPID_, heavy_feature); c_triplet.insert(LIGHT_FEATURE_MAPID_, light_labeled_features_index[heavy_feature_unmodified_sequence]); c_triplet.insert(MEDIUM_FEATURE_MAPID_, medium_labeled_features_index[heavy_feature_unmodified_sequence]); consensus_.push_back(c_triplet); } else { // merge all three channels Feature c2c1 = mergeFeatures_(heavy_feature, AASequence::fromString(heavy_feature_unmodified_sequence), medium_labeled_features_index); Feature completeMerge = mergeFeatures_(c2c1, AASequence::fromString(heavy_feature_unmodified_sequence), light_labeled_features_index); final_feature_map.push_back(completeMerge); } // remove features from indices light_labeled_features_index.erase(heavy_feature_unmodified_sequence); medium_labeled_features_index.erase(heavy_feature_unmodified_sequence); } else if (light_labeled_features_index.has(heavy_feature_unmodified_sequence)) { // 2.Fall -> c0 - c2 if (heavy_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().isModified()) { // add features to final map final_feature_map.push_back(heavy_feature); final_feature_map.push_back(light_labeled_features_index[heavy_feature_unmodified_sequence]); ConsensusFeature c_triplet; c_triplet.insert(HEAVY_FEATURE_MAPID_, heavy_feature); c_triplet.insert(LIGHT_FEATURE_MAPID_, light_labeled_features_index[heavy_feature_unmodified_sequence]); consensus_.push_back(c_triplet); } else { // merge all three channels Feature completeMerge = mergeFeatures_(heavy_feature, AASequence::fromString(heavy_feature_unmodified_sequence), light_labeled_features_index); final_feature_map.push_back(completeMerge); } // remove features from indices light_labeled_features_index.erase(heavy_feature_unmodified_sequence); } else if (medium_labeled_features_index.has(heavy_feature_unmodified_sequence)) { // 3.Fall -> c1 - c2 if (heavy_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().isModified()) { // add features to final map final_feature_map.push_back(heavy_feature); final_feature_map.push_back(medium_labeled_features_index[heavy_feature_unmodified_sequence]); ConsensusFeature c_triplet; c_triplet.insert(HEAVY_FEATURE_MAPID_, heavy_feature); c_triplet.insert(MEDIUM_FEATURE_MAPID_, medium_labeled_features_index[heavy_feature_unmodified_sequence]); consensus_.push_back(c_triplet); } else { // merge all Feature completeMerge = mergeFeatures_(heavy_feature, AASequence::fromString(heavy_feature_unmodified_sequence), medium_labeled_features_index); final_feature_map.push_back(completeMerge); } // remove features from indices medium_labeled_features_index.erase(heavy_feature_unmodified_sequence); } else { // 4.Fall -> alleine final_feature_map.push_back(heavy_feature); } } // clean up medium-labeled_index for (Map<String, Feature>::iterator medium_labeled_index_iter = medium_labeled_features_index.begin(); medium_labeled_index_iter != medium_labeled_features_index.end(); ++medium_labeled_index_iter) { Feature& medium_labeled_feature = medium_labeled_index_iter->second; medium_labeled_feature.ensureUniqueId(); String medium_labeled_feature_unmodified_sequence = medium_labeled_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().toUnmodifiedString(); if (light_labeled_features_index.has(medium_labeled_feature_unmodified_sequence)) { // 1. case: pair between c0 and c1 if (medium_labeled_feature.getPeptideIdentifications()[0].getHits()[0].getSequence().isModified()) { // add features to final map final_feature_map.push_back(medium_labeled_feature); final_feature_map.push_back(light_labeled_features_index[medium_labeled_feature_unmodified_sequence]); ConsensusFeature c_triplet; c_triplet.insert(MEDIUM_FEATURE_MAPID_, medium_labeled_feature); c_triplet.insert(LIGHT_FEATURE_MAPID_, light_labeled_features_index[medium_labeled_feature_unmodified_sequence]); consensus_.push_back(c_triplet); } else { // merge Feature completeMerge = mergeFeatures_(medium_labeled_feature, AASequence::fromString(medium_labeled_feature_unmodified_sequence), light_labeled_features_index); final_feature_map.push_back(completeMerge); } // remove features from indices light_labeled_features_index.erase(medium_labeled_feature_unmodified_sequence); } else { // c1 is alone final_feature_map.push_back(medium_labeled_feature); } } // clean up light-labeled_index for (Map<String, Feature>::iterator light_labeled_index_iter = light_labeled_features_index.begin(); light_labeled_index_iter != light_labeled_features_index.end(); ++light_labeled_index_iter) { // the single ones from c0 final_feature_map.push_back(light_labeled_index_iter->second); } } features_to_simulate.clear(); features_to_simulate.push_back(final_feature_map); consensus_.setProteinIdentifications(final_feature_map.getProteinIdentifications()); ConsensusMap::FileDescription map_description; map_description.label = "Simulation (Labeling Consensus)"; map_description.size = features_to_simulate.size(); consensus_.getFileDescriptions()[0] = map_description; }