Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

ProteinResolver.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: David Wojnar $
00032 // $Authors: David Wojnar $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_ANALYSIS_QUANTITATION_PROTEINRESOLVER_H
00036 #define OPENMS_ANALYSIS_QUANTITATION_PROTEINRESOLVER_H
00037 
00038 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
00039 #include <OpenMS/KERNEL/ConsensusMap.h>
00040 #include <OpenMS/KERNEL/FeatureMap.h>
00041 #include <OpenMS/FORMAT/FASTAFile.h>
00042 #include <OpenMS/METADATA/PeptideIdentification.h>
00043 #include <OpenMS/METADATA/ProteinIdentification.h>
00044 #include <OpenMS/CHEMISTRY/EnzymaticDigestion.h>
00045 
00046 
00047 namespace OpenMS
00048 {
00059   class OPENMS_DLLAPI ProteinResolver :
00060     public DefaultParamHandler
00061   {
00062 
00063 public:
00064 
00065     //default construtor
00066     ProteinResolver();
00067 
00068     //copy constructor
00069     ProteinResolver(const ProteinResolver & rhs);
00070 
00071     //assignment operator
00072     ProteinResolver & operator=(const ProteinResolver & rhs);
00073 
00074     //destructor
00075     virtual ~ProteinResolver();
00076 
00077 
00078     struct ProteinEntry;
00079     struct PeptideEntry;
00080     struct ISDGroup;
00081     struct MSDGroup;
00082     struct ResolverResult;
00083 
00084     //represents a protein from fasta file
00085     struct ProteinEntry
00086     {
00087       std::list<PeptideEntry *> peptides;
00088       bool traversed;
00089       FASTAFile::FASTAEntry * fasta_entry;
00090       enum type  {primary, secondary, primary_indistinguishable, secondary_indistinguishable} protein_type;
00091       DoubleReal weight;    //monoisotopic
00092       Real coverage;    //in percent
00093       //if Protein is indistinguishable all his fellows are in the list indis
00094       std::list<ProteinEntry *> indis;
00095       Size index;
00096       Size  msd_group;     //index
00097       Size  isd_group;     //index
00098       Size number_of_experimental_peptides;
00099     };
00100 
00101     //represents a peptide. First in silco. If experimental is set to true it is MS/MS derived.
00102     struct PeptideEntry
00103     {
00104       std::list<ProteinEntry *> proteins;
00105       bool traversed;
00106       String sequence;
00107       Size peptide_identification;
00108       Size peptide_hit;
00109       Size index;
00110       Size  msd_group;     //index
00111       Size isd_group;     //index
00112       bool experimental;
00113       Real intensity;
00114       String origin;
00115     };
00116 
00117     //representation of an msd group. contains peptides, proteins and a pointer to its ISD group
00118     struct MSDGroup
00119     {
00120       std::list<ProteinEntry *> proteins;
00121       std::list<PeptideEntry *> peptides;
00122       Size index;
00123       ISDGroup * isd_group;
00124       Size number_of_decoy;
00125       Size number_of_target;
00126       Size number_of_target_plus_decoy;
00127       Real intensity;     // intensity of the MSD Group. Defined as the median of the peptide intensities.
00128     };
00129 
00130     struct ISDGroup
00131     {
00132       std::list<ProteinEntry *> proteins;
00133       std::list<PeptideEntry *> peptides;
00134       Size index;
00135       std::list<Size> msd_groups;
00136     };
00137 
00138     struct ResolverResult
00139     {
00140       String identifier;
00141       std::vector<ISDGroup> * isds;
00142       std::vector<MSDGroup> * msds;
00143       std::vector<ProteinEntry> * protein_entries;
00144       std::vector<PeptideEntry> * peptide_entries;
00145       std::vector<Size> * reindexed_peptides;
00146       std::vector<Size> * reindexed_proteins;
00147       enum type  {PeptideIdent, Consensus} input_type;
00148       std::vector<PeptideIdentification> * peptide_identification;
00149       ConsensusMap * consensus_map;
00150     };
00151 
00159     void resolveConsensus(ConsensusMap & consensus);
00160 
00168     void resolveID(std::vector<PeptideIdentification> & peptide_identifications);
00169 
00180     // void writeProteinsAndPeptidesmzTab(std::vector<ProteinEntry>& protein_nodes, std::vector<PeptideEntry>& peptide_nodes, std::vector<Size>& reindexed_proteins, std::vector<Size>& reindexed_peptides, std::vector<PeptideIdentification>& peptide_identifications, String& output  );
00189     void writePeptideTable(std::vector<PeptideEntry> & peptides, std::vector<Size> & reindexed_peptides, std::vector<PeptideIdentification> & identifications, String & output_file);
00198     void writePeptideTable(std::vector<PeptideEntry> & peptides, std::vector<Size> & reindexed_peptides, ConsensusMap & consensus, String & output_file);
00206     void writeProteinTable(std::vector<ProteinEntry> & proteins, std::vector<Size> & reindexed_proteins, String & output_file);
00214     void writeProteinGroups(std::vector<ISDGroup> & isd_groups, std::vector<MSDGroup> & msd_groups, String & output_file);
00215 
00222     void countTargetDecoy(std::vector<MSDGroup> & msd_groups, ConsensusMap & consensus);
00223 
00231     void countTargetDecoy(std::vector<MSDGroup> & msd_groups, std::vector<PeptideIdentification> & peptide_nodes);
00232 
00233     void clearResult();
00234 
00235     void setProteinData(std::vector<FASTAFile::FASTAEntry> & protein_data);
00236 
00237     const  std::vector<ResolverResult> & getResults();
00238 
00239     //overloaded functions -- return a const reference to a PeptideIdentification object or a peptideHit either from a consensusMap or a vector<PeptideIdentification>
00240     const PeptideIdentification & getPeptideIdentification(const ConsensusMap & consensus, const PeptideEntry * peptide);
00241     const PeptideHit & getPeptideHit(const ConsensusMap & consensus, const PeptideEntry * peptide);
00242     const PeptideIdentification & getPeptideIdentification(const std::vector<PeptideIdentification> & peptide_nodes, const PeptideEntry * peptide);
00243     const PeptideHit & getPeptideHit(const std::vector<PeptideIdentification> & peptide_nodes, const PeptideEntry * peptide);
00244 
00245 private:
00246 
00247     std::vector<ResolverResult> resolver_result_;
00248     std::vector<FASTAFile::FASTAEntry> protein_data_;
00249 
00250     void computeIntensityOfMSD_(std::vector<MSDGroup> & msd_groups);
00251 
00252     //travers Protein and peptide nodes. Once for building ISD groups and once for building MSD groups
00253     void traversProtein_(ProteinEntry * prot_node, ISDGroup & group);
00254     void traversProtein_(ProteinEntry * prot_node, MSDGroup & group);
00255     void traversPeptide_(PeptideEntry * pep_node, ISDGroup & group);
00256     void traversPeptide_(PeptideEntry * pep_node, MSDGroup & group);
00257     //searches given sequence in all  nodes and returns its index or nodes.size() if not found.
00258     Size findPeptideEntry_(String seq, std::vector<PeptideEntry> & nodes);
00259     //helper function for findPeptideEntry.
00260     Size binarySearchNodes_(String & seq, std::vector<PeptideEntry> & nodes, Size start, Size end);
00261     //includes all MSMS derived peptides into the graph --idXML
00262     Size includeMSMSPeptides_(std::vector<PeptideIdentification> & peptide_identifications, std::vector<PeptideEntry> & peptide_nodes);
00263     //TODO include run information for each peptide
00264     //includes all MSMS derived peptides into the graph --consensusXML
00265     Size includeMSMSPeptides_(ConsensusMap & consensus, std::vector<PeptideEntry> & peptide_nodes);
00266     //Proteins and Peptides get reindexed, based on whether they belong to msd groups or not. Indexes of Proteins which are in an ISD group but in none of the MSD groups will not be used anymore.
00267     void reindexingNodes_(std::vector<MSDGroup> & msd_groups, std::vector<Size> & reindexed_proteins, std::vector<Size> & reindexed_peptides);
00268     //marks Proteins which have a unique peptide as primary. Uses reindexed vector, thus reindexingNodes has to be called before.
00269     void primaryProteins_(std::vector<PeptideEntry> & peptide_nodes, std::vector<Size> & reindexed_peptides);
00270     void buildingMSDGroups_(std::vector<MSDGroup> & msd_groups, std::vector<ISDGroup> & isd_groups);
00271     void buildingISDGroups_(std::vector<ProteinEntry> & protein_nodes, std::vector<PeptideEntry> & peptide_nodes,
00272                             std::vector<ISDGroup> & isd_groups);
00273     //not tested
00274     //ProteinResolver::indistinguishableProteins(vector<MSDGroup>& msd_groups);
00275 
00276   }; // class
00277 
00278 } // namespace
00279 
00280 #endif // OPENMS_ANALYSIS_QUANTITATION_PROTEINRESOLVER_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:43 using doxygen 1.7.1