// TODO: Support empty PDH in input mzid protected virtual List<ProteinAmbiguityGroupType> BuildProteinDetectionList() { int gid = 1; SortedList<string,ProteinDetectionHypothesisType> list = new SortedList<string, ProteinDetectionHypothesisType>(); List<ProteinAmbiguityGroupType> groups = new List<ProteinAmbiguityGroupType>(); foreach( ProteinAmbiguityGroupType grp in m_mzid.Data.DataCollection.AnalysisData.ProteinDetectionList.ProteinAmbiguityGroup ) foreach( ProteinDetectionHypothesisType pdh in grp.ProteinDetectionHypothesis ) list.Add( pdh.dBSequence_ref, pdh ); foreach( Protein p in Proteins ) { ProteinAmbiguityGroupType g = new ProteinAmbiguityGroupType(); CVParamType ev = new CVParamType(); ev.accession = "MS:1001600"; ev.cvRef = "PSI-MS"; ev.name = "Protein Inference Confidence Category"; switch( p.Evidence ) { case Protein.EvidenceType.Conclusive: ev.value = "conclusive"; break; case Protein.EvidenceType.Indistinguishable: ev.value = "indistinguishable"; break; case Protein.EvidenceType.Group: ev.value = "ambiguous group"; break; case Protein.EvidenceType.NonConclusive: ev.value = "non conclusive"; break; default: continue; } g.id = "PAG_" + gid; gid++; if( p.Subset.Count == 0 ) { //g.ProteinDetectionHypothesis.Add(list[p.DBRef]); g.ProteinDetectionHypothesis = new ProteinDetectionHypothesisType[]{list[p.DBRef]}; g.Items = new CVParamType[]{ev}; } else { List<ProteinDetectionHypothesisType> listpdh = new List<ProteinDetectionHypothesisType>(); foreach( Protein p2 in p.Subset ) { ProteinDetectionHypothesisType pdh = list[p2.DBRef]; pdh.Items = new CVParamType[]{ev}; listpdh.Add( pdh ); } g.ProteinDetectionHypothesis = listpdh.ToArray(); } groups.Add( g ); } return groups; }
private List<ProteinAmbiguityGroupType> BuildPags() { int gid = 1; SortedList<string,ProteinDetectionHypothesisType> listPdh = new SortedList<string, ProteinDetectionHypothesisType>(); SortedList<string,ProteinAmbiguityGroupType> listPag = new SortedList<string, ProteinAmbiguityGroupType>(); List<ProteinAmbiguityGroupType> groups = new List<ProteinAmbiguityGroupType>(); // Collect existing PDHs foreach( ProteinAmbiguityGroupType grp in m_mzid.Data.DataCollection.AnalysisData.ProteinDetectionList.ProteinAmbiguityGroup ) foreach( ProteinDetectionHypothesisType pdh in grp.ProteinDetectionHypothesis ) if( !listPdh.ContainsKey(pdh.dBSequence_ref) ) listPdh.Add( pdh.dBSequence_ref, pdh ); // Build PAGs for every group except non-conclusive proteins foreach( Protein p in Proteins ) { if( p.Evidence == Protein.EvidenceType.NonConclusive || p.Evidence == Protein.EvidenceType.Filtered ) continue; ProteinAmbiguityGroupType g = new ProteinAmbiguityGroupType(); g.id = "PAG_" + gid++; if( p.Subset.Count == 0 ) { g.ProteinDetectionHypothesis = new ProteinDetectionHypothesisType[]{listPdh[p.DBRef]}; UpdatePdhCvs(g.ProteinDetectionHypothesis[0],p.Evidence); listPag.Add(g.ProteinDetectionHypothesis[0].dBSequence_ref,g); } else { List<ProteinDetectionHypothesisType> tmp = new List<ProteinDetectionHypothesisType>(); foreach( Protein p2 in p.Subset ) { ProteinDetectionHypothesisType pdh = listPdh[p2.DBRef]; UpdatePdhCvs(pdh,p2.Evidence); tmp.Add( pdh ); listPag.Add(pdh.dBSequence_ref,g); } g.ProteinDetectionHypothesis = tmp.ToArray(); } groups.Add( g ); } // Include non-conclusive proteins in existing PAGs bool include; foreach( Protein p in Proteins ) { if( p.Evidence != Protein.EvidenceType.NonConclusive ) continue; ProteinDetectionHypothesisType pdh = listPdh[p.DBRef]; UpdatePdhCvs(pdh, Protein.EvidenceType.NonConclusive); foreach( Peptide f in p.Peptides ) foreach( Protein t in f.Proteins ) { include = true; if( !listPag.ContainsKey(t.DBRef) ) continue; ProteinAmbiguityGroupType g = listPag[t.DBRef]; foreach( ProteinDetectionHypothesisType h in g.ProteinDetectionHypothesis ) if( GetBaseId(h) == GetBaseId(pdh) ) { include = false; break; } if( include ) { ProteinDetectionHypothesisType clon = ClonePDH(pdh); clon.id = GetBaseId(clon)+"@"+g.id; List<ProteinDetectionHypothesisType> tmp = new List<ProteinDetectionHypothesisType>(g.ProteinDetectionHypothesis); tmp.Add(clon); g.ProteinDetectionHypothesis = tmp.ToArray(); } } } return groups; }