// constructor public MapperUnit(ushort referenceIndex, int start, int end, MapperUnitType id) : base(referenceIndex, start, end) { ID = id; _hashCode = End.GetHashCode() ^ ID.GetHashCode() ^ ReferenceIndex.GetHashCode() ^ Start.GetHashCode(); }
public void GetMaxOffset_MissingAllOverlappingBins_ReturnMaxOffset() { const ulong expectedResults = ulong.MaxValue; var idToChunks = new Dictionary <int, Interval[]>(); var refSeq = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, null); ulong observedResults = SearchUtilities.GetMaxOffset(refSeq, 243171329); Assert.Equal(expectedResults, observedResults); }
public override int GetHashCode() { var hashCode = ReferenceIndex.GetHashCode() ^ Start.GetHashCode() ^ End.GetHashCode() ^ EntrezGeneId.GetHashCode() ^ EnsemblId.GetHashCode() ^ _hgncId.GetHashCode(); if (Symbol != null) { hashCode ^= Symbol.GetHashCode(); } return(hashCode); }
public Gene(ushort referenceIndex, int start, int end, string stableId, bool onReverseStrand) : base(referenceIndex, start, end) { StableId = stableId; _onReverseStrand = onReverseStrand; _hashCode = End.GetHashCode() ^ _onReverseStrand.GetHashCode() ^ ReferenceIndex.GetHashCode() ^ StableId.GetHashCode() ^ Start.GetHashCode(); }
public void Test_FhirUri_Referance_IndexSetter_GoodFormat_NoMatchOnServiceRootUrl() { //Arrange string ServiceRootUrlString = "http://SomeWhere.net.au/FhirApi/Patient"; string ReferanceUrlString = "http://SomeWhereElse.net.au/FhirApi/Encounter/10"; IFhirUri ReferanceFhirUri = Pyro.Common.CommonFactory.GetFhirUri(new Uri(ReferanceUrlString)); var FhirUri = new FhirUri(); FhirUri.Value = ReferanceUrlString; //Mok the inbound Request Url, this contains the service root url from the db. Mock <IDtoFhirRequestUri> MockIDtoFhirRequestUri = new Mock <IDtoFhirRequestUri>(); var ServiceRootUrl = new Uri(ServiceRootUrlString); IFhirUri RequestFhirUri = Pyro.Common.CommonFactory.GetFhirUri(ServiceRootUrl); MockIDtoFhirRequestUri.Setup(x => x.FhirUri).Returns(RequestFhirUri); var ServiceDtoRootUrlStore = new Pyro.Common.BusinessEntities.Dto.DtoRootUrlStore(); ServiceDtoRootUrlStore.Id = 1; ServiceDtoRootUrlStore.IsServersPrimaryUrlRoot = true; ServiceDtoRootUrlStore.Url = ServiceRootUrlString; MockIDtoFhirRequestUri.Setup(x => x.PrimaryRootUrlStore).Returns(ServiceDtoRootUrlStore); //Mok the response from the db from the Common repository, this if request Url does not match service root url Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository> MockICommonRepository = new Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository>(); var ReferanceRootUrlStore = new Pyro.DataModel.DatabaseModel.ServiceRootURL_Store(); ReferanceRootUrlStore.ServiceRootURL_StoreID = 0; ReferanceRootUrlStore.IsServersPrimaryUrlRoot = false; ReferanceRootUrlStore.RootUrl = ReferanceFhirUri.ServiceRootUrlForComparison; MockICommonRepository.Setup(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison)).Returns(ReferanceRootUrlStore); ReferenceIndex Index = new ReferenceIndex(); //Act Index = IndexSetterFactory.Create(typeof(ReferenceIndex)).Set(FhirUri, Index, MockIDtoFhirRequestUri.Object, MockICommonRepository.Object) as ReferenceIndex; //Assert Assert.AreEqual(Index.FhirId, ReferanceFhirUri.Id); Assert.AreEqual(Index.Type, ReferanceFhirUri.ResourseType); Assert.IsNotNull(Index.Url); Assert.AreEqual(Index.Url.ServiceRootURL_StoreID, 0); Assert.IsFalse(Index.Url.IsServersPrimaryUrlRoot); Assert.AreEqual(Index.Url.RootUrl, ReferanceFhirUri.ServiceRootUrlForComparison); Assert.IsNull(Index.VersionId); Assert.IsNull(Index.ServiceRootURL_StoreID); //Test GetAndOrAddPyro_RootUrlStore called once to add or get the Url from / to the db Assert.DoesNotThrow(() => MockICommonRepository.Verify(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison), Times.Once)); }
public Exon(ushort referenceIndex, int start, int end, string stableId, bool onReverseStrand, byte?phase) : base(referenceIndex, start, end) { _stableId = stableId; OnReverseStrand = onReverseStrand; Phase = phase; _hashCode = End.GetHashCode() ^ OnReverseStrand.GetHashCode() ^ ReferenceIndex.GetHashCode() ^ _stableId.GetHashCode() ^ Start.GetHashCode(); }
public void GetMaxOffset_Nominal() { const ulong expectedResults = 3591443312067; var idToChunks = new Dictionary <int, Interval[]> { [6311] = new[] { new Interval(3591443312067, 3592132724129) } }; var refSeq = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, null); ulong observedResults = SearchUtilities.GetMaxOffset(refSeq, 26699126); Assert.Equal(expectedResults, observedResults); }
public void GetMaxOffset_MissingBin() { const ulong expectedResults = 3724057593420; var idToChunks = new Dictionary <int, Interval[]> { [6878] = new[] { new Interval(3724057593420, 3724057615020) } }; var refSeq = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, null); ulong observedResults = SearchUtilities.GetMaxOffset(refSeq, 35962881); Assert.Equal(expectedResults, observedResults); }
public void GetMaxOffset_MissingFirstBin() { const ulong expectedResults = 3724908138137; var idToChunks = new Dictionary <int, Interval[]> { [860] = new[] { new Interval(3724908138137, 3724908155075) } }; var refSeq = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, null); ulong observedResults = SearchUtilities.GetMaxOffset(refSeq, 36028417); Assert.Equal(expectedResults, observedResults); }
public void Test_ResourceReference_Referance_IndexSetter_GoodFormat_MatchesServiceRootUrl() { //Arrange string ServiceRootUrl = "http://somewhere.net.au/FhirApi/Patient"; string ReferanceUrl = "http://somewhere.net.au/FhirApi/Encounter/10"; IFhirUri ReferanceFhirUri = Common.CommonFactory.GetFhirUri(new Uri(ReferanceUrl)); var ResourceReference = new ResourceReference(); ResourceReference.Reference = ReferanceUrl; //Mok the inbound Request Url, this contains the service root url from the db. Mock <IDtoFhirRequestUri> MockIDtoFhirRequestUri = new Mock <IDtoFhirRequestUri>(); var RootUrl = new Uri(ServiceRootUrl); IFhirUri RequestFhirUri = Common.CommonFactory.GetFhirUri(RootUrl); MockIDtoFhirRequestUri.Setup(x => x.FhirUri).Returns(RequestFhirUri); var DtoRootUrlStore = new Pyro.Common.BusinessEntities.Dto.DtoRootUrlStore(); DtoRootUrlStore.Id = 1; DtoRootUrlStore.IsServersPrimaryUrlRoot = true; DtoRootUrlStore.Url = ServiceRootUrl; MockIDtoFhirRequestUri.Setup(x => x.PrimaryRootUrlStore).Returns(DtoRootUrlStore); //Mok the response from the db from the Common repository, this if request Url does not match service root url Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository> MockICommonRepository = new Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository>(); var RootUrlStore = new Pyro.DataModel.DatabaseModel.ServiceRootURL_Store(); RootUrlStore.ServiceRootURL_StoreID = 0; RootUrlStore.IsServersPrimaryUrlRoot = false; RootUrlStore.RootUrl = ReferanceFhirUri.ServiceRootUrlForComparison; MockICommonRepository.Setup(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison)).Returns(RootUrlStore); ReferenceIndex Index = new ReferenceIndex(); //Act Index = IndexSetterFactory.Create(typeof(ReferenceIndex)).Set(ResourceReference, Index, MockIDtoFhirRequestUri.Object, MockICommonRepository.Object) as ReferenceIndex; //Assert Assert.AreEqual(Index.FhirId, ReferanceFhirUri.Id); Assert.AreEqual(Index.Type, ReferanceFhirUri.ResourseType); Assert.AreEqual(Index.ServiceRootURL_StoreID, 1); Assert.IsNull(Index.Url); Assert.IsNull(Index.VersionId); //Test GetAndOrAddPyro_RootUrlStore not called because Reference url root matches server root url Assert.DoesNotThrow(() => MockICommonRepository.Verify(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison), Times.Never())); }
public void GetMinOffset_MissingBin() { const ulong expectedResults = 3723191187417; var linearFileOffsets = new ulong[2196]; linearFileOffsets[2195] = expectedResults; var idToChunks = new Dictionary <int, Interval[]> { [6876] = new[] { new Interval(1, 1) } }; var refSeq = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, linearFileOffsets); ulong observedResults = SearchUtilities.GetMinOffset(refSeq, 35979265); Assert.Equal(expectedResults, observedResults); }
public void GetMinOffset_Nominal() { const ulong expectedResults = 3591443256775; var linearFileOffsets = new ulong[1630]; linearFileOffsets[1629] = expectedResults; var idToChunks = new Dictionary <int, Interval[]> { [6310] = new[] { new Interval(1, 1) } }; var refSeq = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, linearFileOffsets); ulong observedResults = SearchUtilities.GetMinOffset(refSeq, 26699125); Assert.Equal(expectedResults, observedResults); }
public void GetOffset_Nominal() { var linearFileOffsets = new ulong[1630]; linearFileOffsets[1629] = 3591443256775; var idToChunks = GetIdToChunks(); var refSeqs = new ReferenceIndex[2]; refSeqs[1] = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, linearFileOffsets); var index = new Index(Constants.VcfFormat, 0, 0, 0, '#', 0, refSeqs, _refNameToTabixIndex); long observedResult = index.GetOffset("chr2", 26699126); Assert.Equal(3591443256857, observedResult); }
public void Test_FhirUri_Referance_IndexSetter_Uri_Is_RelativeUri() { //Info: This is a Uri that is not a Fhir resource reference, it is actually a GUID expressed as a Uri. //In this case as it is not a FhirUriReferance we want to return null as it is not searchable as a //Search parameter type of Reference. //Arrange string ServiceRootUrlString = "http://SomeWhere.net.au/FhirApi/Patient"; string ReferanceUrlString = "Encounter/10"; IFhirUri ReferanceFhirUri = Common.CommonFactory.GetFhirUri(ReferanceUrlString); //IFhirUri ReferanceFhirUri = new Pyro.Common.BusinessEntities.UriSupport.DtoFhirUri(ReferanceUrlString); FhirUri FhirUri = new FhirUri(); FhirUri.Value = ReferanceUrlString; //Mok the inbound Request Url, this contains the service root url from the db. Mock <IDtoFhirRequestUri> MockIDtoFhirRequestUri = new Mock <IDtoFhirRequestUri>(); var ServiceRootUrl = new Uri(ServiceRootUrlString); IFhirUri RequestFhirUri = Pyro.Common.CommonFactory.GetFhirUri(ServiceRootUrl); MockIDtoFhirRequestUri.Setup(x => x.FhirUri).Returns(RequestFhirUri); var ServiceDtoRootUrlStore = new Pyro.Common.BusinessEntities.Dto.DtoRootUrlStore(); ServiceDtoRootUrlStore.Id = 1; ServiceDtoRootUrlStore.IsServersPrimaryUrlRoot = true; ServiceDtoRootUrlStore.Url = ServiceRootUrlString; MockIDtoFhirRequestUri.Setup(x => x.PrimaryRootUrlStore).Returns(ServiceDtoRootUrlStore); //Mok the response from the db from the Common repository, this if request Url does not match service root url Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository> MockICommonRepository = new Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository>(); ReferenceIndex Index = new ReferenceIndex(); //Act Index = IndexSetterFactory.Create(typeof(ReferenceIndex)).Set(FhirUri, Index, MockIDtoFhirRequestUri.Object, MockICommonRepository.Object) as ReferenceIndex; //Assert Assert.AreEqual(Index.FhirId, ReferanceFhirUri.Id); Assert.AreEqual(Index.Type, ReferanceFhirUri.ResourseType); Assert.IsNull(Index.Url); Assert.IsNull(Index.VersionId); Assert.AreEqual(Index.ServiceRootURL_StoreID, 1); Assert.DoesNotThrow(() => MockICommonRepository.Verify(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison), Times.Never)); }
public void GetMinOffset_MissingFirstBin() { const ulong expectedResults = 4351134646660; var linearFileOffsets = new ulong[5353]; linearFileOffsets[5352] = expectedResults; var idToChunks = new Dictionary <int, Interval[]> { [1254] = new[] { new Interval(1, 1) } }; var refSeq = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, linearFileOffsets); ulong observedResults = SearchUtilities.GetMinOffset(refSeq, 87687168); Assert.Equal(expectedResults, observedResults); }
public void GetTabixReferenceSequence_Nominal() { var linearFileOffsets = new ulong[1630]; linearFileOffsets[1629] = 3591443256775; var idToChunks = GetIdToChunks(); var refSeqs = new ReferenceIndex[2]; refSeqs[1] = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, linearFileOffsets); var index = new Index(Constants.VcfFormat, 0, 0, 0, '#', 0, refSeqs, _refNameToTabixIndex); var refSeq = index.GetTabixReferenceSequence("chr2"); Assert.Equal("chr2", refSeq.Chromosome.UcscName); }
public void GetOffset_NoOverlappingBins_UseLinearIndex_WithTruncatedIndex_ReturnMinusOne() { var linearFileOffsets = new ulong[1]; linearFileOffsets[0] = 11418; var idToChunks = new Dictionary <int, Interval[]>(); var refSeqs = new ReferenceIndex[2]; refSeqs[0] = new ReferenceIndex(ChromosomeUtilities.Chr1, idToChunks, linearFileOffsets); var index = new Index(Constants.VcfFormat, 0, 0, 0, '#', 0, refSeqs, _refNameToTabixIndex); long observedResult = index.GetOffset("chr1", 100_000); Assert.Equal(-1, observedResult); }
public Slice(ushort referenceIndex, int start, int end, bool onReverseStrand, bool isCircular, bool isTopLevel, CoordSystem coordSystem, int sequenceRegionLen, string sequenceRegionName) : base(referenceIndex, start, end) { _onReverseStrand = onReverseStrand; _isCircular = isCircular; _isTopLevel = isTopLevel; CoordinateSystem = coordSystem; _sequenceRegionLen = sequenceRegionLen; _sequenceRegionName = sequenceRegionName; _hashCode = End.GetHashCode() ^ _isCircular.GetHashCode() ^ _isTopLevel.GetHashCode() ^ _onReverseStrand.GetHashCode() ^ ReferenceIndex.GetHashCode() ^ _sequenceRegionLen.GetHashCode() ^ _sequenceRegionName.GetHashCode() ^ Start.GetHashCode(); }
/// <summary> /// generates the hash code /// </summary> private void GenerateHashCode() { _hashCode = BioType.GetHashCode() ^ CompDnaCodingEnd.GetHashCode() ^ CompDnaCodingStart.GetHashCode() ^ End.GetHashCode() ^ IsCanonical.GetHashCode() ^ OnReverseStrand.GetHashCode() ^ ReferenceIndex.GetHashCode() ^ Start.GetHashCode(); if (CcdsId != null) _hashCode ^= CcdsId.GetHashCode(); if (DatabaseId != null) _hashCode ^= DatabaseId.GetHashCode(); if (ProteinId != null) _hashCode ^= ProteinId.GetHashCode(); if (RefSeqId != null) _hashCode ^= RefSeqId.GetHashCode(); if (GeneStableId != null) _hashCode ^= GeneStableId.GetHashCode(); if (StableId != null) _hashCode ^= StableId.GetHashCode(); if (Gene != null) _hashCode ^= Gene.GetHashCode(); if (Slice != null) _hashCode ^= Slice.GetHashCode(); }
public void Test_ResourceReference_Referance_IndexSetter_Uri_Is_Not_A_Fhir_Referance_Uri() { //Info: This is a Uri that is not a Fhir resource reference, it is actually a GUID expressed as a Uri. //In this case as it is not a FhirUriReferance we want to return null as it is not searchable as a //Search parameter type of Reference. //Arrange string ServiceRootUrlString = "http://SomeWhere.net.au/FhirApi/Patient"; string ReferanceUrlString = "urn:uuid:53fefa32-fcbb-4ff8-8a92-55ee120877b7"; var ResourceReference = new ResourceReference(); ResourceReference.Reference = ReferanceUrlString; //Mok the inbound Request Url, this contains the service root url from the db. Mock <IDtoFhirRequestUri> MockIDtoFhirRequestUri = new Mock <IDtoFhirRequestUri>(); var ServiceRootUrl = new Uri(ServiceRootUrlString); IFhirUri RequestFhirUri = Common.CommonFactory.GetFhirUri(ServiceRootUrl); MockIDtoFhirRequestUri.Setup(x => x.FhirUri).Returns(RequestFhirUri); var ServiceDtoRootUrlStore = new Pyro.Common.BusinessEntities.Dto.DtoRootUrlStore(); ServiceDtoRootUrlStore.Id = 1; ServiceDtoRootUrlStore.IsServersPrimaryUrlRoot = true; ServiceDtoRootUrlStore.Url = ServiceRootUrlString; MockIDtoFhirRequestUri.Setup(x => x.PrimaryRootUrlStore).Returns(ServiceDtoRootUrlStore); //Mok the response from the db from the Common repository, this if request Url does not match service root url Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository> MockICommonRepository = new Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository>(); ReferenceIndex Index = new ReferenceIndex(); //Act Index = IndexSetterFactory.Create(typeof(ReferenceIndex)).Set(ResourceReference, Index, MockIDtoFhirRequestUri.Object, MockICommonRepository.Object) as ReferenceIndex; //Assert Assert.IsNull(Index); Assert.DoesNotThrow(() => MockICommonRepository.Verify(x => x.GetAndOrAddService_RootUrlStore(ReferanceUrlString), Times.Never)); }
public void GetOffset_FixNegativeBeginCoordinate() { var linearFileOffsets = new ulong[1]; linearFileOffsets[0] = 3213608733669; var idToChunks = new Dictionary <int, Interval[]> { [585] = new[] { new Interval(3213608740412, 3213608740487) }, [4681] = new[] { new Interval(3213608733669, 3213608740412) }, [4682] = new[] { new Interval(3213608740487, 3214303562687) } }; var refSeqs = new ReferenceIndex[2]; refSeqs[1] = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, linearFileOffsets); var index = new Index(Constants.VcfFormat, 0, 0, 0, '#', 0, refSeqs, _refNameToTabixIndex); long observedResult = index.GetOffset("chr2", 0); Assert.Equal(3213608733669, observedResult); }
public void GetOffset_HandleDiff_TabixIndex_And_RefIndex() { var linearFileOffsets = new ulong[1630]; linearFileOffsets[1629] = 3591443256775; var idToChunks = GetIdToChunks(); // tabix index 10 = chr2 = ref index 1 var refSeqs = new ReferenceIndex[11]; refSeqs[10] = new ReferenceIndex(ChromosomeUtilities.Chr2, idToChunks, linearFileOffsets); var refNameToTabixIndex = new Dictionary <string, ushort> { ["chr2"] = 10 }; var index = new Index(Constants.VcfFormat, 0, 0, 0, '#', 0, refSeqs, refNameToTabixIndex); long observedResult = index.GetOffset("chr2", 26699126); Assert.Equal(3591443256857, observedResult); }