private void QueryPeptideProteins(ILongWaitBroker longWaitBroker) { List <HashSet <Protein> > peptideProteins = new List <HashSet <Protein> >(); if (BackgroundProteome != null) { using (var proteomeDb = BackgroundProteome.OpenProteomeDb()) { Digestion digestion = BackgroundProteome.GetDigestion(proteomeDb, SrmDocument.Settings.PeptideSettings); foreach (var peptideDocNode in _peptideDocNodes) { HashSet <Protein> proteins = new HashSet <Protein>(); if (digestion != null) { if (longWaitBroker.IsCanceled) { return; } foreach (Protein protein in digestion.GetProteinsWithSequence(peptideDocNode.Peptide.Sequence)) { if (protein.Sequence == PeptideGroupDocNode.PeptideGroup.Sequence) { _targetIsInBackgroundProteome = true; continue; } proteins.Add(protein); } } peptideProteins.Add(proteins); } } } _peptideProteins = peptideProteins; }
public Species CreateSpecies(string name, int searing, int nLegs, Digestion digestion, int movingThreshold, int swimmingThreshold, int reprooductionCosts, int stamina, int herdBehaviour, int maximumStrength, int minimumStrength) { var species = new Species(name, searing, nLegs, digestion, movingThreshold, swimmingThreshold, reprooductionCosts, stamina, herdBehaviour, maximumStrength, minimumStrength); Species.Add(species); return(species); }
private void QueryPeptideProteins(ILongWaitBroker longWaitBroker) { List <HashSet <Protein> > peptideProteins = new List <HashSet <Protein> >(); if (BackgroundProteome != null) { using (var proteomeDb = BackgroundProteome.OpenProteomeDb(longWaitBroker.CancellationToken)) { Digestion digestion = proteomeDb.GetDigestion(); if (digestion != null) { var peptidesOfInterest = _peptideDocNodes.Select(node => node.Item2.Peptide.Target.Sequence); var sequenceProteinsDict = digestion.GetProteinsWithSequences(peptidesOfInterest); if (longWaitBroker.IsCanceled) { return; } foreach (var tuple in _peptideDocNodes) { if (longWaitBroker.IsCanceled) { return; } var peptideGroup = (PeptideGroup)tuple.Item1.GetIdentity(0); var peptideDocNode = tuple.Item2; HashSet <Protein> proteins = new HashSet <Protein>(); var peptideGroupDocNode = PeptideGroupDocNodes.First(g => ReferenceEquals(g.PeptideGroup, peptideGroup)); List <Protein> proteinsForSequence; if (sequenceProteinsDict.TryGetValue(peptideDocNode.Peptide.Target.Sequence, out proteinsForSequence)) { if (peptideGroupDocNode != null) { foreach (var protein in proteinsForSequence) { if (protein.Sequence == peptideGroupDocNode.PeptideGroup.Sequence) { _peptidesInBackgroundProteome.Add(tuple.Item1); continue; } proteins.Add(protein); } } } peptideProteins.Add(proteins); } } } } _peptideProteins = peptideProteins; }
/// <summary> /// Create a new species /// </summary> /// <param name="name">The name of the species</param> /// <param name="searing">Percentage of stamina where the creature still wants to mate</param> /// <param name="nLegs"> /// The number of legs of the creature. /// This must be an equal number, equal to or higher then 2 /// </param> /// <param name="digestion"> /// What the creature will eat /// - Carnivore: The creature will eat other creatures /// - Herbivore: The creature will eat plants /// - OmnivoreCreature: The creature can eat both plants and other creatures, with a preference for other creatures /// - OmnivorePlant: The creature can eat both plants and other creatures, with a preference for Plants /// - Nonivore: The creature cannot eat anything /// </param> /// <param name="movingThreshold">The percentage of the stamina where the creature can still move</param> /// <param name="swimmingThreshold">The percentage of the stamina where the creature want to swim</param> /// <param name="reproductionCosts"> /// Percentage of stamina that is transferred to the child /// This must be lower then searing /// </param> /// <param name="stamina">The maximum amount of energy a creature can have</param> /// <param name="herdBehaviour"> /// The redius in which a creature is attracted to others of it's species /// When this numnber is 0, the creature will not be attracted /// </param> /// <param name="maximumStrength">The maximum strength a creature can have</param> /// <param name="minimumStrength">The minimum strength a creature can haves</param> public Species(string name, int searing, int nLegs, Digestion digestion, int movingThreshold, int swimmingThreshold, int reproductionCosts, int stamina, int herdBehaviour, int maximumStrength, int minimumStrength) { Name = name; Stamina = stamina; NLegs = nLegs; Searing = searing; Digestion = digestion; MovingThreshold = movingThreshold; SwimmingThreshold = swimmingThreshold; ReproductionCosts = reproductionCosts; Herbehaviour = herdBehaviour; MaximumStrength = maximumStrength; MinimumStrength = minimumStrength; }
private void QueryPeptideProteins(ILongWaitBroker longWaitBroker) { List <HashSet <Protein> > peptideProteins = new List <HashSet <Protein> >(); if (BackgroundProteome != null) { using (var proteomeDb = BackgroundProteome.OpenProteomeDb()) { Digestion digestion = BackgroundProteome.GetDigestion(proteomeDb, SrmDocument.Settings.PeptideSettings); if (digestion != null) { var peptidesOfInterest = _peptideDocNodes.Select(node => node.Peptide.Sequence); var sequenceProteinsDict = digestion.GetProteinsWithSequences(peptidesOfInterest, null); if (longWaitBroker.IsCanceled) { return; } foreach (var peptideDocNode in _peptideDocNodes) { HashSet <Protein> proteins = new HashSet <Protein>(); var peptideGroupDocNode = PeptideGroupDocNodes.First(g => g.Peptides.Contains(peptideDocNode)); List <Protein> proteinsForSequence; if (sequenceProteinsDict.TryGetValue(peptideDocNode.Peptide.Sequence, out proteinsForSequence)) { if (peptideGroupDocNode != null) { foreach (var protein in proteinsForSequence) { if (protein.Sequence == peptideGroupDocNode.PeptideGroup.Sequence) { _peptidesInBackgroundProteome.Add(peptideDocNode); continue; } proteins.Add(protein); } } } peptideProteins.Add(proteins); } } } } _peptideProteins = peptideProteins; }
public void TestProteomeDb() { using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE)) { string fastaPath = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta"); string protDbPath = testFilesDir.GetTestPath("test.protdb"); using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath)) { IProgressStatus status = new ProgressStatus(string.Empty); using (var reader = new StreamReader(fastaPath)) { proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, true); // Delay indexing } // perform digestion Digestion digestion = proteomeDb.GetDigestion(); var digestedProteins0 = digestion.GetProteinsWithSequence("EDGWVK"); Assert.IsTrue(digestedProteins0.Count >= 1); } } }
public void TestProteomeDb() { using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE)) { string fastaPath = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta"); string protDbPath = testFilesDir.GetTestPath("test.protdb"); using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath)) { Enzyme trypsin = EnzymeList.GetDefault(); using (var reader = new StreamReader(fastaPath)) { proteomeDb.AddFastaFile(reader, (msg, progress) => true); } // perform digestion proteomeDb.Digest(new ProteaseImpl(trypsin), (msg, progress) => true); Digestion digestion = proteomeDb.GetDigestion(trypsin.Name); var digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100); Assert.IsTrue(digestedProteins0.Count >= 1); } } }
public void TestProteomeDb() { using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE)) { string fastaPath = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta"); string protDbPath = testFilesDir.GetTestPath("test.protdb"); using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath)) { Enzyme trypsin = EnzymeList.GetDefault(); IProgressStatus status = new ProgressStatus(string.Empty); using (var reader = new StreamReader(fastaPath)) { proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, true); // Delay indexing } // perform digestion proteomeDb.Digest(new ProteaseImpl(trypsin), ProteomeDb.PROTDB_MAX_MISSED_CLEAVAGES, new SilentProgressMonitor(), ref status); Digestion digestion = proteomeDb.GetDigestion(trypsin.Name); var digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100); Assert.IsTrue(digestedProteins0.Count >= 1); } } }
/// <summary> /// Add the creatures of a given digestion to the SimulationContext /// The species will be equally devided for the digestion /// </summary> /// <param name="digestion">The creatures digestion</param> /// <param name="percentage">The percentage of the creature with the digestion in the simulation</param> private void AddCreatures(Digestion digestion, int percentage) { var species = _species.Where(sp => sp.Digestion == digestion); var speciesCount = species.Count(); double p; if (digestion == Digestion.OmnivorePlant || digestion == Digestion.OmnivoreCreature) { var omnivores = _species.Where( sp => sp.Digestion == Digestion.OmnivoreCreature || sp.Digestion == Digestion.OmnivorePlant); var omnivoreCount = omnivores.Count(); p = percentage / Math.Pow(speciesCount, 2) / omnivoreCount; } else { p = (double)percentage / (double)speciesCount; } foreach (var s in species) { AddSimObjects <Creature>(Convert.ToInt32(p), s); } }
public static bool Run() { //TODO test GPU instead DBOptions dbOptions = MhcSample.CreateOptions(""); Dictionary <string, int> sequences = new Dictionary <string, int>(); List <Protein> proteins = Propheus.ReadProteomeFromFasta(Path.Combine(Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]), "UnitTest", "proteins.fasta"), false, dbOptions);//ETLPAMCNVYYVNCMAPLTE string sequence = proteins[0].BaseSequence; double[] proteinMasses = new double[sequence.Length]; List <double> precursors = new List <double>(); for (int i = 0; i < sequence.Length; i++) { for (int j = i + dbOptions.MinimumPeptideLength - 1; j < sequence.Length; j++) { int size = j - i + 1; if (size <= dbOptions.MaximumPeptideLength) { string subStr = sequence.Substring(i, j - i + 1); if (!sequences.ContainsKey(subStr)) { sequences.Add(subStr, 1); } else { sequences[subStr]++; } double mass = Constants.WATER_MONOISOTOPIC_MASS; for (int k = 0; k < subStr.Length; k++) { mass += AminoAcidMasses.GetMonoisotopicMass(subStr[k]); } precursors.Add(mass); } } proteinMasses[i] = AminoAcidMasses.GetMonoisotopicMass(sequence[i]); } precursors.Sort(); Queries queries = new Queries(dbOptions, precursors.ToArray()); Digestion ps = new Digestion(dbOptions); List <Protein> lProt = new List <Protein>(); lProt.Add(proteins[0]); //for each protein, build matrix of mass //Trinity_Gpu.ProteinDigest pg = new Trinity_Gpu.ProteinDigest(precursors.ToArray(), sequence.Length); //Test twice to test that precursor list stays in gpu memory for (int iter = 0; iter < 2; iter++) { Dictionary <string, int> sequencesTmp = new Dictionary <string, int>(sequences); foreach (Tuple <Peptide, int> item in ps.DigestProteomeOnTheFlyNoEnzyme(lProt, queries)) { sequencesTmp[item.Item1.BaseSequence] -= 1;//TODO add modifications } /* * foreach (Trinity_Gpu.ProteinPrecursorMatch match in pg.Execute(proteinMasses, 0.00005, 10000000))//TODO compute correct tolerance window * { * int size = match.proteinEndPos - match.proteinStartPos; * string str = sequence.Substring(match.proteinStartPos, size); * if (size >= dbOptions.MinimumPeptideLength) * { * sequencesTmp[str] -= 1;//TODO add modifications * } * }//*/ foreach (int val in sequencesTmp.Values) { if (val != 0) { return(false);//*/ } } } //pg.Dispose(); return(true); }
CreatureReportInfo(int totalCount, int totalEnergy, Digestion digestion) { }
public Species CreateSpecies(string Name, int Searing, int NLegs, Digestion digestion, int MovingThreshold, int SwimmingThreshold, int RepoductionCosts, int Stamina, int HerdBehaviour) { throw new NotImplementedException(); }
/// <summary> /// Get creatures of a specific digestion type /// </summary> /// <param name="digestion">Digestion type</param> /// <returns> /// List of creatures of a specific digestion type /// Null if there are no creatures of the digestion type /// </returns> public ReadOnlyCollection <Creature> GetCreatures(Digestion digestion) { var creatures = GetCreatures().Where(c => c.Species.Digestion == digestion).ToList().AsReadOnly(); return(creatures); }