public void PossibleGhostsFromEvidence(Evidences evidences, params Ghost[] expected) { var actual = evidences.GetGhosts().ToList(); Assert.Equal(expected.Length, actual.Count); Assert.Equal(expected.OrderBy(o => o), actual.OrderBy(o => o)); }
public XDocument Serialize() { return(new XDocument(new XElement(EspdNames.Qarp + nameof(QualificationApplicationResponse), new XAttribute(XNamespace.Xmlns + "cbc", UblNames.Cbc), new XAttribute(XNamespace.Xmlns + "cac", UblNames.Cac), UBLVersionID.Serialize(nameof(UBLVersionID)), CustomizationID.Serialize(nameof(CustomizationID)), ProfileID.Serialize(nameof(ProfileID)), ID?.Serialize(nameof(ID)), CopyIndicator.Serialize(nameof(CopyIndicator)), UUID.Serialize(nameof(UUID)), ContractFolderID.Serialize(nameof(ContractFolderID)), IssueDate.Serialize(nameof(IssueDate)), IssueTime.Serialize(nameof(IssueTime)), EconomicOperatorGroupName.Serialize(nameof(EconomicOperatorGroupName)), VersionID.Serialize(nameof(VersionID)), PreviousVersionID.Serialize(nameof(PreviousVersionID)), ProcedureCode.Serialize(nameof(ProcedureCode)), QualificationApplicationTypeCode.Serialize(nameof(QualificationApplicationTypeCode)), WeightScoringMethodologyNote.Serialize(nameof(WeightScoringMethodologyNote)), WeightingTypeCode.Serialize(nameof(WeightingTypeCode)), ContractingParty?.Serialize(), EconomicOperatorParty?.Serialize(nameof(EconomicOperatorParty)), ProcurementProject?.Serialize(), ProcurementProjectLots?.Select(lot => lot.Serialize()), TenderingCriteria?.Select(c => c.Serialize()), TenderingCriterionResponses?.Select(r => r.Serialize()), AdditionalDocumentReferences?.Select(d => d.Serialize()), Evidences?.Select(e => e.Serialize()) ))); }
public void GhostsFromFoundAndEliminatedEvidence(Evidences found, Evidences eliminated, params Ghost[] expected) { var actual = found.GetGhosts(eliminated).ToList(); Assert.Equal(expected.Length, actual.Count); Assert.Equal(expected.OrderBy(o => o), actual.OrderBy(o => o)); }
/// <inheritdoc /> public WhenRecordingNewConsent_ForAnExistingStudySubject_WithoutActiveConsent() { A.CallTo(() => Consents.FindActiveConsent(StudySubject)) .Returns(null); RecordConsent( Evidences.ServerMedwayDto(takenBy: "Peter Crowther"), 2.January(1837)); }
public static IEnumerable <Ghost> GetGhosts(this Evidences found, Evidences eliminated) { var left = found.GetGhosts(); var right = eliminated.GetEliminatedGhosts(); return(from l in left from r in right where l == r select l); }
public static IEnumerable <Ghost> GetEliminatedGhosts(this Evidences evidences) { foreach (Ghost ghost in Enum.GetValues(typeof(Ghost))) { if (((Evidences)ghost & evidences) == 0) { yield return(ghost); } } }
/// <summary> /// Calculate average mass and net and stdev mass and net for each Target. /// </summary> public void CalculateStatistics() { var massesList = Evidences.Select(c => c.MonoisotopicMass).ToList(); var netList = Evidences.Select(c => c.ObservedNet).ToList(); TheoreticalMonoIsotopicMass = massesList.Average(); AverageNet = netList.Average(); StdevNet = (netList.Count == 1) ? 0 : netList.StandardDeviation(); }
public void ShouldCreateANewConsentRecord() { Assert.NotNull(CreatedConsent); Assert.Equal(StudyId, CreatedConsent.StudySubject.StudyId); Assert.Same(StudySubject, CreatedConsent.StudySubject); Assert.Equal(StudySubject.PersonId, CreatedConsent.GivenByPersonId); Assert.Equal(2.January(1837), CreatedConsent.DateGiven); Assert.Equal(Evidences.MedwayEvidence(takenBy: "Peter Crowther"), CreatedConsent.GivenEvidence.Single()); }
/// <inheritdoc /> public WhenRecordingConsent_ForANewStudySubject() { newSubjectIdentifier = StudySubject.SubjectIdentifier + "New"; newPersonId = StudySubject.PersonId.Id + 1; A.CallTo(() => StudySubjects.GetStudySubject(StudyId, newSubjectIdentifier)).Returns(null); A.CallTo(() => StudySubjects.FindStudySubject(StudyId, new PersonIdentity(newPersonId))).Returns(null); A.CallTo(() => StudySubjects.AddStudySubject(A <StudySubject> ._)) .Invokes((StudySubject created) => createdStudySubject = created); RecordConsent(Evidences.ServerMedwayDto(takenBy: "Michael Fish"), A.Dummy <DateTime>(), subjectIdentifier: newSubjectIdentifier, personId: newPersonId); }
public void CorrectlyParsesFullConsent() { var consent = ParseConsent( @"<consent date-given=""2017-03-12"" study-id=""42""> <givenBy> <match><identifier type=""nhs-number"">8877881</identifier></match> <match><identifier type=""bradford-hospital-number"">1122112</identifier></match> </givenBy> <evidence> <evidence type=""medway""> <evidence type=""competent-status"">Delegated</evidence> <evidence type=""consent-given-by"">Mother</evidence> <evidence type=""consent-taken-by"">Betsey Trotwood</evidence> </evidence> </evidence> </consent>", personIdentifierTypes: Identifiers.Registry, KnownEvidence.Registry ); consent.GivenBy .Should() .BeEquivalentTo( new IdentifierMatchSpecification(Identifiers.Definitions.NhsNumber.Value("8877881")), new IdentifierMatchSpecification(Identifiers.Definitions.HospitalNumber.Value("1122112")) ); Assert.Collection( consent.Evidence, e => { e.Should().BeEquivalentTo( Evidences.ClientMedwayDto("Delegated", "Mother", "Betsey Trotwood"), o => o.RespectingRuntimeTypes() ); }, e => { e.Should().BeEquivalentTo( KnownEvidence.ImportFile.ClientDto( KnownEvidence.ImportFileParts.BaseUri.ClientDto(XmlImportFileBaseUri), KnownEvidence.ImportFileParts.LineNumber.ClientDto(1), KnownEvidence.ImportFileParts.LinePosition.ClientDto(2) ), o => o.RespectingRuntimeTypes() ); } ); }
public void ReturnsDataAboutDefinitions() { var definitions = new[] { Evidences.String("TestString"), Evidences.Enum("TestEnum", "Yes", "No") }; var controller = new MetaController(new EvidenceDefinitionRegistry(definitions)); var result = controller.Get(); result.Should().BeOfType <OkObjectResult>() .Which .Value.Should().BeEquivalentTo(definitions); }
public void SavesConsent() { var consentContext = Server.Host.Services.GetService <ConsentContext>(); var study = consentContext.Add(new StudyEntity { Name = Random.String() }).Entity; var person = consentContext.Add(new PersonEntity()).Entity; consentContext.SaveChanges(); var result = ApiClient.PutConsent( new ConsentSpecification { StudyId = study.Id, DateGiven = Random.Date().Date, GivenBy = person.Id, PersonId = person.Id, SubjectIdentifier = Random.String(15), Evidence = new [] { Evidences.ClientMedwayDto(status: "Competent", givenBy: "Self", takenBy: "Jackson Pollock"), } }); Assert.NotNull(result); var newConsentId = Assert.IsType <long>(result); var consentEntity = consentContext.Set <ConsentEntity>() .Include(_ => _.StudySubject) .ThenInclude(_ => _.Study) .Include(_ => _.StudySubject) .ThenInclude(_ => _.Person) .Include(_ => _.GivenBy) .Single(_ => _.Id == newConsentId); Assert.NotNull(consentEntity); var evidence = consentContext.Set <GivenEvidenceEntity>().SingleOrDefault(_ => _.Consent.Id == newConsentId); using (new AssertionScope()) { evidence.Should().NotBeNull(); evidence.Value.Should().Be( "<medway><competent-status>Competent</competent-status><consent-given-by>Self</consent-given-by><consent-taken-by>Jackson Pollock</consent-taken-by></medway>"); evidence.Type.Should().Be("medway"); } }
/// <inheritdoc /> public JsonSerializationTests(ITestOutputHelper output) { this.output = output; registry = KnownEvidence.Registry; serializerSettings = ConfigureJsonOptions.ConfigureSerializer( new JsonSerializerSettings(), new XunitLogger <IIdentifierValueDtoJsonConverter>( output, "test")); consentSpecification = new ConsentSpecification { Evidence = new[] { Evidences.ServerMedwayDto(givenBy: "Self", takenBy: "Nurse Brown"), Evidences.ServerImportFileDto("test.xml", line: 15, offset: 12), } }; }
public void StoresConsentGivenEvidenceWhenAddingConsent() { var subjectIdentifier = Random.String(); var(personId, _, studySubject) = CreateStudySubject(subjectIdentifier); var dateGiven = Random.Date().Date; var evidence = Evidences.MedwayEvidence(competencyStatus: "Competent", takenBy: "Nurse Randall"); var marshalledEvidence = new CompositeIdentifierXmlMarshaller <Evidence, EvidenceDefinition>(KnownEvidence.Medway) .MarshallToXml(evidence) .ToString(SaveOptions.DisableFormatting); var consent = CreateConsentRepository(updateContext) .AddConsent( new Common.Consent.Consent(studySubject, dateGiven, personId, new [] { evidence }) ); updateContext.SaveChanges(); var savedConsent = readContext.Set <ConsentEntity>().AsNoTracking() .Where(_ => _.Id == consent.Id) .Include(_ => _.GivenEvidence) .SingleOrDefault(); savedConsent.Should().NotBeNull(); savedConsent.GivenEvidence.Should().ContainSingle(); var storedEvidence = savedConsent.GivenEvidence.SingleOrDefault(); storedEvidence.Should().NotBeNull().And.BeOfType <GivenEvidenceEntity>(); Assert.Equal(KnownEvidence.Medway.SystemName, storedEvidence.Type); Assert.Equal(marshalledEvidence, storedEvidence.Value); Assert.NotNull(storedEvidence.Consent); }
public void ArrayFromFlagsEnum(Evidences before, params Evidences[] expected) { var actual = before.GetFlags().ToList(); Assert.Equal(expected, actual); }
protected void CreateEvidences(string evidencesName) { Evidences veirfy = new Evidences(Driver, evidencesName); Logger.LogWrite($"Evidences created for {evidencesName}"); }
/// <summary> /// Add another evidence of the ConsensusTarget /// </summary> /// <param name="evidence"></param> public void AddEvidence(Evidence evidence) { Evidences.Add(evidence); if (Sequence == null) { Sequence = evidence.Sequence; } evidence.Sequence = Sequence; if (Math.Abs(PredictedNet) < double.Epsilon) { PredictedNet = evidence.PredictedNet; } // For rebuilding and getting the predicted NET into Evidence // when reloading back into the data objects evidence.PredictedNet = PredictedNet; if (MultiProteinCount == 0) { MultiProteinCount = evidence.MultiProteinCount; } evidence.MultiProteinCount = MultiProteinCount; if (string.IsNullOrWhiteSpace(ModificationDescription)) { ModificationDescription = evidence.ModificationDescription; } evidence.ModificationDescription = ModificationDescription; if (ModificationCount == 0) { ModificationCount = evidence.ModificationCount; } evidence.ModificationCount = ModificationCount; if (evidence.Ptms.Count != 0 && Ptms.Count == 0) { foreach (var ptm in evidence.Ptms) { Ptms.Add(ptm); ptm.Parent = this; } } var tempList = Ptms.ToList(); tempList.Sort((x, y) => x.Location.CompareTo(y.Location)); // Copy sequence as is up until you hit a modification //For numeric, add a bracket add +/- and copy the mass //For non numeric, add a bracket add +/- and copy the formula var numeric = ""; var nonNumeric = ""; var cleanSeq = ""; var sequencePos = 0; var symbolsRemoved = 0; string partialSeq; foreach (var ptm in tempList) { partialSeq = Sequence.Substring(sequencePos, (ptm.Location + PreCharCount + symbolsRemoved) - sequencePos); cleanSeq += partialSeq; numeric += partialSeq + string.Format("[{0}{1}]", ((ptm.Mass > 0) ? "+" : "-"), ptm.Mass); nonNumeric += partialSeq + string.Format("[{0}{1}]", ((ptm.Mass > 0) ? "+" : "-"), ptm.Formula); sequencePos = ptm.Location + PreCharCount; // To skip over non-alphanumeric characters in the sequence such as "*" or "&" // which can be used to denote ptms in .txt files, but not skip over "." or "-" // which are standard characters in peptide sequences to separate peptide from // pre/post residues and to denote the lack of a pre/post residue respectively int indexCheck = sequencePos + symbolsRemoved; if ((Sequence[indexCheck] != 46 && Sequence[indexCheck] != 45) && (Sequence[indexCheck] < 65 || Sequence[indexCheck] > 90)) { sequencePos += ++symbolsRemoved; } } partialSeq = Sequence.Substring(sequencePos); cleanSeq += partialSeq; numeric += partialSeq; nonNumeric += partialSeq; StrippedSequence = cleanSeq; var pieces = cleanSeq.Split('.'); if (pieces.Count() != 1) { PrefixResidue = pieces[0].First(); StrippedSequence = pieces[1]; SuffixResidue = pieces[2].First(); } if (string.IsNullOrWhiteSpace(evidence.CleanPeptide)) { //evidence.CleanPeptide = cleanSeq; evidence.CleanPeptide = StrippedSequence; } CleanSequence = cleanSeq; if (string.IsNullOrWhiteSpace(evidence.EncodedNonNumericSequence)) { evidence.EncodedNonNumericSequence = nonNumeric; } EncodedNonNumericSequence = nonNumeric; if (string.IsNullOrWhiteSpace((evidence.SeqWithNumericMods))) { evidence.SeqWithNumericMods = numeric; } EncodedNumericSequence = numeric; if (!Charges.Contains(evidence.Charge)) { Charges.Add(evidence.Charge); } evidence.Parent = this; }