public IEnumerable <ISimplePosition> Recompose(List <ISimplePosition> simplePositions, List <int> functionBlockRanges) { var positionSet = PositionSet.CreatePositionSet(simplePositions, functionBlockRanges); var alleleSet = positionSet.AlleleSet; var alleleIndexBlockToSampleIndex = positionSet.AlleleBlockToSampleHaplotype; int numSamples = positionSet.NumSamples; _sequenceProvider.LoadChromosome(alleleSet.Chromosome); int regionStart = alleleSet.Starts[0]; string lastRefAllele = alleleSet.VariantArrays.Last()[0]; int regionEnd = alleleSet.Starts.Last() + lastRefAllele.Length + 100; // make it long enough if (regionEnd > _sequenceProvider.Sequence.Length) { regionEnd = _sequenceProvider.Sequence.Length; } string totalRefSequence = _sequenceProvider.Sequence.Substring(regionStart - 1, regionEnd - regionStart); // VCF positions are 1-based var recomposedAlleleSet = new RecomposedAlleleSet(positionSet.ChrName, numSamples); foreach (var(alleleIndexBlock, sampleAlleles) in alleleIndexBlockToSampleIndex) { (int start, _, string refAllele, string altAllele, var varPosIndexesInAlleleBlock, List <string> decomposedVids) = GetPositionsAndRefAltAlleles(alleleIndexBlock, alleleSet, totalRefSequence, regionStart, simplePositions); var variantSite = new VariantSite(start, refAllele); if (!recomposedAlleleSet.RecomposedAlleles.TryGetValue(variantSite, out var variantInfo)) { variantInfo = GetVariantInfo(positionSet, alleleIndexBlock); recomposedAlleleSet.RecomposedAlleles[variantSite] = variantInfo; } variantInfo.AddAllele(altAllele, sampleAlleles, decomposedVids); variantInfo.UpdateSampleFilters(varPosIndexesInAlleleBlock, sampleAlleles); } return(recomposedAlleleSet.GetRecomposedPositions(_sequenceProvider.RefNameToChromosome)); }
public void LoadData(ObservableCollection <PlaceData> listOfPlaces) { string pathData = Properties.Settings.Default.Path + Properties.Settings.Default.DataFileName; string[] lines = System.IO.File.ReadAllLines(pathData, UTF8Encoding.UTF8); // , UTF8Encoding.UTF7 PositionSet positionSet; foreach (string line in lines) { PlaceData placeData = new PlaceData(); string[] data = line.Split('|'); placeData.PlaceIndex = Int32.Parse(data[0]); placeData.PlaceId = Int32.Parse(data[1]); placeData.PlaceName = data[2]; for (int i = 3; i < data.GetUpperBound(0); i = i + 2) { positionSet = new PositionSet(data[i].ConvertStringToVertex(), data[i + 1].ConvertStringToVertex()); placeData.PositionList.Add(positionSet); } listOfPlaces.Add(placeData); } }
private static VariantInfo GetVariantInfo(PositionSet positionSet, AlleleIndexBlock alleleIndexBlock) { string filter = "PASS"; var positions = positionSet.SimplePositions; var startIndex = alleleIndexBlock.PositionIndex; var numPositions = alleleIndexBlock.AlleleIndexes.Count; var numSamples = positionSet.NumSamples; string[] quals = new string[numPositions]; for (int i = startIndex; i < startIndex + numPositions; i++) { quals[i - startIndex] = positions[i].VcfFields[VcfCommon.QualIndex]; string thisFilter = positions[i].VcfFields[VcfCommon.FilterIndex]; if (filter == "PASS" && thisFilter != "PASS" && thisFilter != ".") { filter = FailedFilterTag; } } string qual = GetStringWithMinValueOrDot(quals); string[] gqValues = new string[numSamples]; for (int i = 0; i < numSamples; i++) { gqValues[i] = GetStringWithMinValueOrDot(new ArraySegment <string>(positionSet.GqInfo[i], startIndex, numPositions).ToArray()); } string[] psValues = new string[numSamples]; for (int i = 0; i < numSamples; i++) { // PS tags are the same in the decomposed variants psValues[i] = positionSet.PsInfo[i][startIndex]; } return(new VariantInfo(qual, filter, gqValues, psValues)); }
private void SetScale(object sender, Pose pose) { markerHolder.localScale = Vector3.one * lastMessage.PhysicalSideLength; markerDisplay.SetActive(true); PositionSet?.Invoke(this, pose); audioSource.Play(); }
public PositionSet(PositionSet other) : this(bwapiPINVOKE.new_PositionSet__SWIG_1(PositionSet.getCPtr(other)), true) { if (bwapiPINVOKE.SWIGPendingException.Pending) { throw bwapiPINVOKE.SWIGPendingException.Retrieve(); } }
public PositionSetEnumerator(PositionSet collection) { collectionRef = collection; keyCollection = new global::System.Collections.Generic.List <Position>(collection.Values); currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; }
public void GetPhaseSetTagIndexes_NoPS_Return_NegativeOne() { var position = new Mock<ISimplePosition>(); var vcfFields = new string[VcfCommon.MinNumColumnsSampleGenotypes]; vcfFields[VcfCommon.FormatIndex] = "GT"; position.SetupGet(x => x.VcfFields).Returns(vcfFields); var functionBlockRanges = new List<int> { 102 }; var positionSet = new PositionSet(new List<ISimplePosition> { position.Object }, functionBlockRanges); Assert.Equal(new[] { new []{-1} }, positionSet.GetSampleTagIndexes(new[] { "PS" })); }
private static VariantInfo GetVariantInfo(PositionSet positionSet, AlleleBlock alleleBlock) { var positions = positionSet.SimplePositions; int startIndex = alleleBlock.PositionIndex; int numPositions = alleleBlock.AlleleIndexes.Length; int numSamples = positionSet.NumSamples; string qual = GetStringWithMinValueOrDot(Enumerable.Range(startIndex, numPositions) .Select(x => positions[x].VcfFields[VcfCommon.QualIndex])); var filters = Enumerable.Range(startIndex, numPositions) .Select(i => positions[i].VcfFields[VcfCommon.FilterIndex]) .ToArray(); var gqValues = new string[numSamples]; for (var i = 0; i < numSamples; i++) { gqValues[i] = GetStringWithMinValueOrDot( new ArraySegment <string>(positionSet.GqInfo.Values[i], startIndex, numPositions).ToArray()); } var psValues = new string[numSamples]; for (var i = 0; i < numSamples; i++) { var psTagsThisSample = new ArraySegment <string>(positionSet.PsInfo.Values[i], startIndex, numPositions); var isHomozygous = new ArraySegment <bool>( positionSet.GtInfo.Values[i].Select(x => x.IsHomozygous).ToArray(), startIndex, numPositions); psValues[i] = GetPhaseSetForRecomposedVariant(psTagsThisSample, isHomozygous); } var homoReferenceSamplePloidy = new int?[numSamples]; for (var i = 0; i < numSamples; i++) { if (Genotype.IsAllHomozygousReference(positionSet.GtInfo.Values[i], startIndex, numPositions)) { homoReferenceSamplePloidy[i] = positionSet.GtInfo.Values[i][startIndex].AlleleIndexes.Length; } } var sampleFilters = new List <bool> [numSamples]; for (var i = 0; i < numSamples; i++) { sampleFilters[i] = new List <bool>(); } return(new VariantInfo(qual, filters, gqValues, psValues, homoReferenceSamplePloidy, sampleFilters)); }
public void InsertInPosition(BadgeEventSet be, FieldSet f, double posX, double posY, string fontFamily, int fontSize) { PositionSet p = new PositionSet(); p.BadgeEventSet = be; p.FieldSet = f; p.Position_X = posX; p.Position_Y = posY; p.FontFamily = fontFamily; p.FontSize = fontSize; p.FontStyle = System.Drawing.FontStyle.Regular.ToString(); var repo = this._repostitoryFactory.GetPositionRepository(this._dbContext); repo.Insert(p); repo.SaveChanges(); }
public void GetPhaseSetTagIndexes_Return_Correct_PSIndex() { var position1 = new Mock<ISimplePosition>(); var vcfFields1 = new string[VcfCommon.MinNumColumnsSampleGenotypes]; vcfFields1[VcfCommon.FormatIndex] = "GT:PS"; position1.SetupGet(x => x.VcfFields).Returns(vcfFields1); var position2 = new Mock<ISimplePosition>(); var vcfFields2 = new string[VcfCommon.MinNumColumnsSampleGenotypes]; vcfFields2[VcfCommon.FormatIndex] = "GT:AA:PS"; position2.SetupGet(x => x.VcfFields).Returns(vcfFields2); var position3 = new Mock<ISimplePosition>(); var vcfFields3 = new string[VcfCommon.MinNumColumnsSampleGenotypes]; vcfFields3[VcfCommon.FormatIndex] = "GT:AA:BB:PS"; position3.SetupGet(x => x.VcfFields).Returns(vcfFields3); var positionSet = new PositionSet(new List<ISimplePosition> { position1.Object, position2.Object, position3.Object }, new List<int>()); Assert.Equal(new[] {new[] { 1, 2, 3 }}, positionSet.GetSampleTagIndexes(new[] { "PS" })); }
public IEnumerable <ISimplePosition> Recompose(List <ISimplePosition> recomposablePositions, List <int> functionBlockRanges) { var positionSet = PositionSet.CreatePositionSet(recomposablePositions, functionBlockRanges); var alleleSet = positionSet.AlleleSet; var alleleIndexBlockToSampleIndex = positionSet.AlleleIndexBlockToSampleIndex; var numSamples = positionSet.NumSamples; _sequenceProvider.LoadChromosome(alleleSet.Chromosome); int regionStart = alleleSet.Starts[0]; string lastRefAllele = alleleSet.VariantArrays.Last()[0]; int regionEnd = alleleSet.Starts.Last() + lastRefAllele.Length + 100; // make it long enough if (regionEnd > _sequenceProvider.Sequence.Length) { regionEnd = _sequenceProvider.Sequence.Length; } string totalRefSequence = _sequenceProvider.Sequence.Substring(regionStart - 1, regionEnd - regionStart); // VCF positions are 1-based var recomposedAlleleSet = new RecomposedAlleleSet(positionSet.ChrName, numSamples); var decomposedPosVarIndex = new HashSet <(int PosIndex, int VarIndex)>(); foreach (var(alleleIndexBlock, sampleAlleles) in alleleIndexBlockToSampleIndex) { var(start, _, refAllele, altAllele) = GetPositionsAndRefAltAlleles(alleleIndexBlock, alleleSet, totalRefSequence, regionStart, decomposedPosVarIndex); var variantSite = new VariantSite(start, refAllele); if (!recomposedAlleleSet.RecomposedAlleles.TryGetValue(variantSite, out var variantInfo)) { variantInfo = GetVariantInfo(positionSet, alleleIndexBlock); recomposedAlleleSet.RecomposedAlleles[variantSite] = variantInfo; } variantInfo.AddAllele(altAllele, sampleAlleles); } // Set decomposed tag to positions used for recomposition foreach (var indexTuple in decomposedPosVarIndex) { recomposablePositions[indexTuple.PosIndex].IsDecomposed[indexTuple.VarIndex] = true; } return(recomposedAlleleSet.GetRecomposedVcfRecords().Select(x => SimplePosition.GetSimplePosition(x, _sequenceProvider.RefNameToChromosome, true))); }
protected virtual void RaiseProgressSetEvent(object sender, ProgressEventArgs e) => InvokeActionOnMainThread(() => PositionSet?.Invoke(sender, e));
public virtual PositionSet getNukeDots() { PositionSet ret = new PositionSet(bwapiPINVOKE.Game_getNukeDots(swigCPtr), false); return(ret); }
public void ExtractSamplePhaseSet_NegativePSIndex_ReturnDot() { Assert.Equal(".", PositionSet.ExtractSampleValue(-1, new[] { "0|1", "." })); }
public override PositionSet getNukeDots() { PositionSet ret = new PositionSet(bwapiclientPINVOKE.GameImpl_getNukeDots(swigCPtr), false); return ret; }
public void showData() { Radix radix = agent.rpCase.radix; lbl_datetime.Text = radix.datetime; lbl_location.Text = radix.location; lbl_coordinates.Text = radix.coordinatesText; PositionSet positionSet = radix.positionSet; ArrayList planetaryPositions = positionSet.planetaryPositions; dgvPositions.CellBorderStyle = DataGridViewCellBorderStyle.None; dgvPositions.RowsDefaultCellStyle.BackColor = Color.AliceBlue; dgvPositions.AlternatingRowsDefaultCellStyle.BackColor = Color.NavajoWhite; DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col6 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col7 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col8 = new DataGridViewTextBoxColumn(); col2.HeaderText = ResourceBundle.RB_FRM_SHOWPOSITIONS_TXT_LONGITUDE; col4.HeaderText = ResourceBundle.RB_FRM_SHOWPOSITIONS_TXT_LATITUDE; col5.HeaderText = ResourceBundle.RB_FRM_SHOWPOSITIONS_TXT_RIGHTASCENSION; col6.HeaderText = ResourceBundle.RB_FRM_SHOWPOSITIONS_TXT_DECLINATION; col7.HeaderText = ResourceBundle.RB_FRM_SHOWPOSITIONS_TXT_SPEED; col8.HeaderText = ResourceBundle.RB_FRM_SHOWPOSITIONS_TXT_DISTANCE; col1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; col2.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; col3.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; col4.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; col5.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; col6.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; col7.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; col8.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; col1.DefaultCellStyle.Font = listBodyGlyphs; col1.Width = 24; col3.DefaultCellStyle.Font = listSignGlyphs; col3.Width = 24; col2.SortMode = DataGridViewColumnSortMode.NotSortable; col3.SortMode = DataGridViewColumnSortMode.NotSortable; col4.SortMode = DataGridViewColumnSortMode.NotSortable; col5.SortMode = DataGridViewColumnSortMode.NotSortable; col6.SortMode = DataGridViewColumnSortMode.NotSortable; col7.SortMode = DataGridViewColumnSortMode.NotSortable; col8.SortMode = DataGridViewColumnSortMode.NotSortable; dgvPositions.Columns.AddRange( new DataGridViewTextBoxColumn[] { col1, col2, col3, col4, col5, col6, col7, col8 }); int nrOfBodies = radix.positionSet.planetaryPositions.Count; int nrOfRows = Math.Max(nrOfBodies, 20); DataGridViewRow[] dgvr = new DataGridViewRow[nrOfBodies]; ArrayList pos = radix.positionSet.planetaryPositions; PlanetaryPosition pp; for (int i = 0; i < nrOfBodies; i++) { pp = (PlanetaryPosition)pos[i]; dgvr[i] = new DataGridViewRow(); dgvr[i].CreateCells(dgvPositions); dgvr[i].Cells[0].Value = Conversions.bodyGlyphFromIndex(pp.planetId); dgvr[i].Cells[1].Value = Conversions.deg2sexagesimal(pp.longitude, true, true); dgvr[i].Cells[2].Value = Conversions.signGlyphFromLong(pp.longitude); dgvr[i].Cells[3].Value = Conversions.deg2sexagesimalInRange(pp.latitude, -180, 180, true); dgvr[i].Cells[4].Value = Conversions.deg2sexagesimal(pp.rightAscension, true, false); dgvr[i].Cells[5].Value = Conversions.deg2sexagesimalInRange(pp.declination, -90.0, 90.0, true); dgvr[i].Cells[6].Value = Conversions.deg2sexagesimalInRange(pp.speedLongitude, -90.0, 90.0, true); dgvr[i].Cells[7].Value = Conversions.fixedFraction(pp.distance, 6); } dgvPositions.Rows.AddRange(dgvr); lbl_name.Text = radix.name; }
public void ExtractSamplePhaseSet_PSIsDot_ReturnDot() { Assert.Equal(".", PositionSet.ExtractSampleValue(1, new[] { "0|1", "." })); }
public virtual PositionSet getNukeDots() { PositionSet ret = new PositionSet(bwapiPINVOKE.Game_getNukeDots(swigCPtr), false); return ret; }
private void SetScale(object sender, Pose pose) { PositionSet?.Invoke(this, pose); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PositionSet obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public void ExtractSamplePhaseSet_PSIsNum_ReturnTheNum() { Assert.Equal("123", PositionSet.ExtractSampleValue(1, new[] { "0|1", "123" })); }
/// <summary> /// Analysis for a radix, supports a set of analysing techniques /// </summary> /// <param name="positionSet">Postions of bodies and houses</param> /// <param name="aspectTypes">Supported aspecttypes</param> /// <param name="midpointOrb">Orbis for midpoints</param> public RadixAnalysis(PositionSet positionSet, ArrayList aspectTypes, double midpointOrb) { aspectsAnalysis = new AspectsAnalysis(aspectTypes, positionSet.planetaryPositions, positionSet.housePositionSet); midpointsAnalysis = new MidpointsAnalysis(positionSet.planetaryPositions, positionSet.housePositionSet, midpointOrb); }
public static ObservableCollection <PlaceData> ImportData() { ObservableCollection <PlaceData> listOfData = new ObservableCollection <PlaceData>(); PositionSet positionSet; string process; int startIndex; try { string pathData = Properties.Settings.Default.Path + Properties.Settings.Default.ImportFileName; string[] lines = System.IO.File.ReadAllLines(pathData, UTF8Encoding.UTF7); foreach (string line in lines) { PlaceData place = new PlaceData(); process = line; startIndex = line.IndexOf("("); if (startIndex > 0) { process = process.Substring(startIndex + 2); } else { process = process.Substring(1); } // check if line contain data formatted as expected int indexPosition = process.IndexOf("\'"); if (indexPosition > 0) { // parse index at end of line int index; Int32.TryParse(process.Substring(indexPosition + 1), out index); place.PlaceIndex = index; // remove trailing 'x [index] process = process.Substring(0, indexPosition - 1); // remove trailing ") indexPosition = process.IndexOf("\")"); process = process.Substring(0, indexPosition); // data ready - parse to object string[] data = process.Split('|'); place.PlaceId = Int32.Parse(data[0]); place.PlaceName = data[1]; for (int i = 2; i < data.GetUpperBound(0); i = i + 2) { positionSet = new PositionSet(data[i].ConvertStringToVertex(), data[i + 1].ConvertStringToVertex()); place.PositionList.Add(positionSet); } } if (indexPosition > 0) // only add to collection if data is meaningfull { listOfData.Add(place); } } } catch (Exception e) { MessageBox.Show("Error while importing data: " + e.Message); } return(listOfData); }