예제 #1
0
        public OverlapType FillOverlap(BarBase bar)
        {
            OverlapType ret = OverlapType.None;

            if (this.PriceLow.Between(bar.PriceLow, bar.PriceHigh))
            {
                ret = OverlapType.Up;
            }
            else if (this.PriceHigh.Between(bar.PriceLow, bar.PriceHigh))
            {
                ret = OverlapType.Down;
            }
            else if (bar.PriceLow.Between(this.PriceLow, this.PriceHigh))
            {
                ret = OverlapType.Down;
            }
            else if (bar.PriceHigh.Between(this.PriceLow, this.PriceHigh))
            {
                ret = OverlapType.Up;
            }
            //else if (bar.PriceLow.Between(this.PriceLow, this.PriceHigh)) ret = OverlapType.Down;
            //else if (this.PriceHigh.Between(bar.PriceLow, bar.PriceHigh)) ret = OverlapType.Down;
            //else if (bar.PriceHigh.Between(this.PriceLow, this.PriceHigh)) ret = OverlapType.Up;
            if (ret != OverlapType.None)
            {
                Overlap = this.StartDate - bar.StartDate;
            }
            return(ret);
        }
예제 #2
0
        private OverlapType GetOverlap()
        {
            if ((_overlap & (int)OverlapType.Initialized) == 0)
            {
                OverlapType o = OverlapType.Initialized;

                // Only instances can be overlapping or overlappable.
                if (IsInstance)
                {
                    foreach (var attribute in GetAttributes())
                    {
                        if (attribute.IsTargetAttribute(this, AttributeDescription.OverlappableAttribute))
                        {
                            o |= OverlapType.Overlappable;
                        }
                        else if (attribute.IsTargetAttribute(this, AttributeDescription.OverlappingAttribute))
                        {
                            o |= OverlapType.Overlapping;
                        }
                    }
                }
                Interlocked.CompareExchange(ref _overlap, (int)o, 0);
            }
            return((OverlapType)_overlap);
        }
예제 #3
0
        public static void Init(OverlapType type)
        {
            var now = DateTime.Now;

            overlapType = type;
            Debug.WriteLine("Keyboard Overlap plugin initialized {0}", now);
        }
예제 #4
0
        public void Elongation(VariantType variantType, OverlapType overlapType, EndpointOverlapType endpointOverlapType, bool expectedResult)
        {
            var  featureEffect  = new FeatureVariantEffects(overlapType, endpointOverlapType, false, variantType, true);
            bool observedResult = featureEffect.Elongation();

            Assert.Equal(expectedResult, observedResult);
        }
예제 #5
0
        public void FivePrimeDuplicatedTranscript(VariantType variantType, OverlapType overlapType, EndpointOverlapType endpointOverlapType,
                                                  bool onReverseStrand, bool expectedResult)
        {
            var  featureEffect  = new FeatureVariantEffects(overlapType, endpointOverlapType, onReverseStrand, variantType, true);
            bool observedResult = featureEffect.FivePrimeDuplicatedTranscript();

            Assert.Equal(expectedResult, observedResult);
        }
예제 #6
0
        public void GetOverlapType(int vStart, int vEnd, OverlapType expectedResults)
        {
            const int tStart = 200;
            const int tEnd   = 400;

            OverlapType observedResults = Utilities.GetOverlapType(tStart, tEnd, vStart, vEnd);

            Assert.Equal(expectedResults, observedResults);
        }
        private static List <ConsequenceTag> GetConsequences(IInterval transcript, bool onReverseStrand, IVariant variant)
        {
            OverlapType         overlapType         = Intervals.Utilities.GetOverlapType(transcript.Start, transcript.End, variant.Start, variant.End);
            EndpointOverlapType endpointOverlapType = Intervals.Utilities.GetEndpointOverlapType(transcript.Start, transcript.End, variant.Start, variant.End);
            var featureEffect = new FeatureVariantEffects(overlapType, endpointOverlapType, onReverseStrand, variant.Type, true);
            var consequence   = new Consequences(variant.Type, null, featureEffect);

            consequence.DetermineStructuralVariantEffect(variant);
            return(consequence.GetConsequences());
        }
예제 #8
0
        public FftUpsampler(int factor, int fftLength, OverlapType overlap)
            : base(FilterType.FftUpsampler)
        {
            Overlap = overlap;

            if (factor <= 1 || !IsPowerOfTwo(factor)) {
                throw new ArgumentException("factor must be power of two integer and larger than 1");
            }
            Factor = factor;

            FftLength = fftLength;
            System.Diagnostics.Debug.Assert(IsPowerOfTwo(FftLength));
        }
예제 #9
0
        public static IAnnotatedRegulatoryRegion Annotate(IVariant variant, IRegulatoryRegion regulatoryRegion)
        {
            OverlapType overlapType = Intervals.Utilities.GetOverlapType(regulatoryRegion.Start, regulatoryRegion.End,
                                                                         variant.Start, variant.End);
            EndpointOverlapType endpointOverlapType =
                Intervals.Utilities.GetEndpointOverlapType(regulatoryRegion.Start, regulatoryRegion.End, variant.Start, variant.End);
            var featureEffect = new FeatureVariantEffects(overlapType, endpointOverlapType, false, variant.Type, variant.IsStructuralVariant);

            var consequence = new Consequences(VariantType.unknown, null, featureEffect);

            consequence.DetermineRegulatoryVariantEffects();
            return(new AnnotatedRegulatoryRegion(regulatoryRegion, consequence.GetConsequences()));
        }
예제 #10
0
        public FftUpsampler(int factor, int fftLength, OverlapType overlap)
            : base(FilterType.FftUpsampler)
        {
            Overlap = overlap;

            if (factor <= 1 || !IsPowerOfTwo(factor))
            {
                throw new ArgumentException("factor must be power of two integer and larger than 1");
            }
            Factor = factor;

            FftLength = fftLength;
            System.Diagnostics.Debug.Assert(IsPowerOfTwo(FftLength));
        }
        private bool CombineFor(MeshInfo meshInfo, List <MeshInfo> meshes, int i)
        {
            MeshInfo mesh1       = meshInfo;
            Vector3  randomPoint = mesh1.Vertices[Random.Range(0, mesh1.Vertices.Count - 1)];

            for (int j = i + 1; j < meshes.Count; j++)
            {
                MeshInfo mesh2 = meshes[j];

                OverlapType type = DetectOverlap(mesh1, mesh2);

                if (type == OverlapType.NotOverlapping)
                {
                    continue;
                }

                if (type == OverlapType.FullyContainedIn1)
                {
                    AllMeshes.Remove(meshes[j]);
                    return(true);
                }

                if (type == OverlapType.FullyContainedIn2)
                {
                    AllMeshes.Remove(meshes[i]);
                    return(true);
                }

                if (type == OverlapType.Overlapping)
                {
                    if (mesh1.Bounds.extents.magnitude > mesh2.Bounds.extents.magnitude)
                    {
                        FixOverlap(mesh1, mesh2);
                    }
                    else
                    {
                        FixOverlap(mesh2, mesh1);
                    }

                    return(true);
                }
            }
            return(false);
        }
예제 #12
0
        public static FilterBase Restore(string[] tokens)
        {
            if (tokens.Length < 2 || 4 < tokens.Length)
            {
                return(null);
            }

            int factor;

            if (!Int32.TryParse(tokens[1], out factor) || factor <= 1 || !IsPowerOfTwo(factor))
            {
                return(null);
            }

            int fftLength = DEFAULT_FFT_LENGTH;

            if (3 <= tokens.Length)
            {
                if (!Int32.TryParse(tokens[2], out fftLength) || fftLength < 1024 || !IsPowerOfTwo(fftLength))
                {
                    return(null);
                }
            }

            OverlapType overlap = OverlapType.Half;

            if (4 <= tokens.Length)
            {
                for (int i = 0; i < (int)OverlapType.NUM; ++i)
                {
                    OverlapType t = (OverlapType)i;
                    if (0 == string.Compare(tokens[3], t.ToString()))
                    {
                        overlap = t;
                    }
                }
            }

            return(new FftUpsampler(factor, fftLength, overlap));
        }
예제 #13
0
        public FeatureVariantEffects(OverlapType overlapType, EndpointOverlapType endpointOverlapType, bool onReverseStrand, VariantType vt,
                                     bool isSv)
        {
            _isSv = isSv;

            _partialOverlap     = overlapType != OverlapType.CompletelyOverlaps && overlapType != OverlapType.None;
            _completelyOverlaps = overlapType == OverlapType.CompletelyOverlaps;
            _completelyWithin   = overlapType == OverlapType.CompletelyWithin;

            _fivePrimeOverlap = !onReverseStrand && endpointOverlapType == EndpointOverlapType.Start ||
                                onReverseStrand && endpointOverlapType == EndpointOverlapType.End;

            _threePrimeOverlap = !onReverseStrand && endpointOverlapType == EndpointOverlapType.End ||
                                 onReverseStrand && endpointOverlapType == EndpointOverlapType.Start;

            _lossOrDeletion    = vt == VariantType.copy_number_loss || vt == VariantType.deletion;
            _gainOrDuplication = vt == VariantType.copy_number_gain || vt == VariantType.duplication ||
                                 vt == VariantType.tandem_duplication;

            _isInsertionDeletion = vt == VariantType.indel;
            _isInsertion         = vt == VariantType.insertion;
        }
예제 #14
0
            bool MakeStoplineLaneOverlaps(MapStopLineSegmentBuilder stopline, List <MapSegment> lanesToInspec, float stoplineWidth, int overlapInfoId, OverlapType overlapType, ref List <Ros.PointENU> stoplinePts, ref Dictionary <Id, List <Id> > laneId2OverlapIdsMapping, ref List <Id> overlap_ids, ref List <Overlap> overlaps)
            {
                stopline.segment.targetWorldPositions = new List <Vector3>(stopline.segment.targetLocalPositions.Count);
                List <Vector2> stopline2D = new List <Vector2>();

                for (int i = 0; i < stopline.segment.targetLocalPositions.Count; i++)
                {
                    var worldPos = stopline.segment.builder.transform.TransformPoint(stopline.segment.targetLocalPositions[i]);
                    stopline.segment.targetWorldPositions.Add(worldPos); //to worldspace here
                    stopline2D.Add(new Vector2(worldPos.x, worldPos.z));
                    stoplinePts.Add(GetApolloCoordinates(worldPos, OriginEasting, OriginNorthing, false));
                }

                var considered = new HashSet <MapSegment>(); //This is to prevent conceptually or practically duplicated overlaps

                string overlap_id_prefix = "";

                if (overlapType == OverlapType.Signal_Stopline_Lane)
                {
                    overlap_id_prefix = "signal_lane_overlap_";
                }
                else if (overlapType == OverlapType.Stopsign_Stopline_Lane)
                {
                    overlap_id_prefix = "stopsign_lane_overlap_";
                }

                foreach (var seg in lanesToInspec)
                {
                    List <Vector2> intersects;
                    var            lane2D        = seg.targetWorldPositions.Select(p => new Vector2(p.x, p.z)).ToList();
                    bool           isIntersected = Utils.CurveSegmentsIntersect(stopline2D, lane2D, out intersects);
                    if (isIntersected)
                    {
                        Vector2 intersect = intersects[0];

                        if (intersects.Count > 1)
                        {
                            //determin if is cluster
                            Vector2 avgPt     = Vector2.zero;
                            float   maxRadius = proximity;
                            bool    isCluster = true;
                            for (int i = 0; i < intersects.Count; i++)
                            {
                                avgPt += intersects[i];
                            }
                            avgPt /= intersects.Count;
                            for (int i = 0; i < intersects.Count; i++)
                            {
                                if ((avgPt - intersects[i]).magnitude > maxRadius)
                                {
                                    isCluster = false;
                                }
                            }

                            if (isCluster)
                            {
                                //Debug.Log("stopline have multiple intersect points with a lane within a cluster, pick one");
                            }
                            else
                            {
                                //UnityEditor.Selection.activeGameObject = stopLine.gameObject;
                                Debug.LogWarning("stopline is not common to have more than one non-cluster intersect point with a lane, abort calculation");
                                return(false);
                            }
                        }

                        float totalLength;
                        float s = Utils.GetNearestSCoordinate(intersect, lane2D, out totalLength);

                        var segments = new List <MapSegment>();
                        var lengths  = new List <float>();

                        if (totalLength - s < stoplineIntersectThreshold && seg.afters.Count > 0)
                        {
                            s = 0;
                            foreach (var afterSeg in seg.afters)
                            {
                                segments.Add(afterSeg);
                                lengths.Add(Utils.GetCurveLength(afterSeg.targetWorldPositions.Select(p => new Vector2(p.x, p.z)).ToList()));
                            }
                        }
                        else
                        {
                            segments.Add(seg);
                            lengths.Add(totalLength);
                        }

                        for (int i = 0; i < segments.Count; i++)
                        {
                            var segment = segments[i];
                            var segLen  = lengths[i];
                            if (considered.Contains(segment))
                            {
                                continue;
                            }

                            considered.Add(segment);

                            float ln_start_s = s - stoplineWidth * 0.5f;
                            float ln_end_s   = s + stoplineWidth * 0.5f;

                            if (ln_start_s < 0)
                            {
                                var diff = -ln_start_s;
                                ln_start_s += diff;
                                ln_end_s   += diff;
                                if (ln_end_s > segLen)
                                {
                                    ln_end_s = segLen;
                                }
                            }
                            else if (ln_end_s > segLen)
                            {
                                var diff = ln_end_s - segLen;
                                ln_start_s -= diff;
                                ln_end_s   -= diff;
                                if (ln_start_s < 0)
                                {
                                    ln_start_s = 0;
                                }
                            }

                            //Create overlap
                            var overlap_id = $"{overlap_id_prefix}{overlaps.Count}";
                            var lane_id    = segment.hdmapInfo.id;

                            if (!laneId2OverlapIdsMapping.ContainsKey(lane_id))
                            {
                                laneId2OverlapIdsMapping.Add(lane_id, new List <Id>());
                            }
                            laneId2OverlapIdsMapping[lane_id].Add(overlap_id);

                            ObjectOverlapInfo objOverlapInfo = new ObjectOverlapInfo();

                            if (overlapType == OverlapType.Signal_Stopline_Lane)
                            {
                                objOverlapInfo = new ObjectOverlapInfo()
                                {
                                    id           = $"signal_{overlapInfoId}",
                                    overlap_info = new ObjectOverlapInfo.OverlapInfo_OneOf()
                                    {
                                        signal_overlap_info = new SignalOverlapInfo(),
                                    },
                                };
                            }
                            else if (overlapType == OverlapType.Stopsign_Stopline_Lane)
                            {
                                objOverlapInfo = new ObjectOverlapInfo()
                                {
                                    id           = $"stopsign_{overlapInfoId}",
                                    overlap_info = new ObjectOverlapInfo.OverlapInfo_OneOf()
                                    {
                                        stop_sign_overlap_info = new StopSignOverlapInfo(),
                                    },
                                };
                            }

                            overlaps.Add(new Overlap()
                            {
                                id      = overlap_id,
                                @object = new List <ObjectOverlapInfo>()
                                {
                                    new ObjectOverlapInfo()
                                    {
                                        id           = lane_id,
                                        overlap_info = new ObjectOverlapInfo.OverlapInfo_OneOf()
                                        {
                                            lane_overlap_info = new LaneOverlapInfo()
                                            {
                                                start_s  = ln_start_s,
                                                end_s    = ln_end_s,
                                                is_merge = false,
                                            },
                                        },
                                    },
                                    objOverlapInfo,
                                },
                            });

                            overlap_ids.Add(overlap_id);
                        }
                    }
                }

                return(true);
            }