Skip to content

Commit 018ee87

Browse files
committed
fixing protein sequence issue. Also added a condition to check if variants can be written.
1 parent 079bd6f commit 018ee87

2 files changed

Lines changed: 4 additions & 26 deletions

File tree

MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,16 @@ public string ModInfoStringFromGroupedFiles(List<SpectraFileInfo> spectraFiles)
417417

418418
foreach (var protein in proteinGroupOccupanciesPerProtein.Keys)
419419
{
420-
if (!proteinGroupOccupanciesPerProtein[protein].IsNotNullOrEmpty())
420+
if (proteinGroupOccupanciesPerProtein[protein].IsNullOrEmpty())
421421
{
422422
continue;
423423
}
424424

425425
modInfoString.Append(protein.Accession + ":{");
426-
var protSeq = Proteins.Where(prot => prot.Accession == protein.Accession).First().BaseSequence;
427426

428427
foreach (var modpos in proteinGroupOccupanciesPerProtein[protein].Keys.Order())
429428
{
430-
var loc = modpos == 0 ? "N-term" : modpos == protein.Sequence.Length + 1 ? "C-term" : $"{protSeq[modpos-1]}#" + modpos.ToString(); //something's worng with the positions sometimes being longer than the sequence
429+
var loc = modpos == 0 ? "N-terminal" : modpos == protein.Sequence.Length + 1 ? "C-terminal" : $"{protein.Sequence[modpos-1]}#" + modpos.ToString();
431430
modInfoString.Append(loc);
432431

433432
var modStrings = new List<string>();

MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -600,28 +600,7 @@ private void QuantificationAnalysis()
600600

601601
PositionFrequencyAnalysis pfa = new PositionFrequencyAnalysis();
602602
var proteins = proteinGroup.Proteins.Select(p => new KeyValuePair<string, string>(p.Accession, p.BaseSequence)).ToDictionary();
603-
pfa.SetUpQuantificationObjectsFromFullSequences(peptides, proteins); // one-based indexes, ignores terminal mods on all peptides.
604-
605-
// set the one-based start index in protein for each peptide
606-
foreach (var protein in pfa.ProteinGroups.First().Value.Proteins.Values)
607-
{
608-
if (protein.Sequence == null)
609-
{
610-
protein.Sequence = proteinGroup.Proteins.Where(p => p.Accession == protein.Accession).Select(p => p.BaseSequence).First();
611-
}
612-
List<string> peptideBaseSequencesSeen = new List<string>();
613-
foreach (var peptide in proteinGroup.AllPeptides)
614-
{
615-
if (protein.Peptides.ContainsKey(peptide.BaseSequence)
616-
&& !peptideBaseSequencesSeen.Contains(peptide.BaseSequence))
617-
{
618-
protein.Peptides[peptide.BaseSequence]
619-
.OneBasedStartIndexInProtein = peptide.OneBasedStartResidue;
620-
621-
peptideBaseSequencesSeen.Add(peptide.BaseSequence);
622-
}
623-
}
624-
}
603+
pfa.SetUpQuantificationObjectsFromFullSequences(peptides, proteins); // uses zero-based indexes for the mods.
625604

626605
proteinGroup.ModsInfo.Add(spectraFile, pfa.ProteinGroups.First().Value); // Getting stoich one protein group at a time, so only getting First() is ok here.
627606

@@ -1686,7 +1665,7 @@ private void WriteVariantResults()
16861665

16871666
foreach (var variant in variants)
16881667
{
1689-
if (variantPWSM.IntersectsAndIdentifiesVariation(variant).identifies == true)
1668+
if (variantPWSM.IntersectsAndIdentifiesVariation(variant).identifies == true && variant.Description.Description.IsNotNullOrEmpty())
16901669
{
16911670
if (culture.CompareInfo.IndexOf(variant.Description.Description, "missense_variant", CompareOptions.IgnoreCase) >= 0)
16921671
{

0 commit comments

Comments
 (0)