Ejemplo n.º 1
0
 private bool ConsecutiveMatchesAreLongerThanTheQuery(double queryLength, List <MatchedPair> sortedMatches, int index, FingerprintConfiguration config)
 {
     return(SubFingerprintsToSeconds.AdjustLengthToSeconds(
                sortedMatches[index].SubFingerprint.SequenceAt,
                sortedMatches[index - 1].SubFingerprint.SequenceAt,
                config) > queryLength);
 }
Ejemplo n.º 2
0
        public Coverage GetCoverage(SortedSet <MatchedPair> matches, double queryLength, FingerprintConfiguration configuration)
        {
            int minI = 0, maxI = 0, curMinI = 0, maxLength = 0;
            var sortedMatches = matches.ToList();

            for (int i = 1; i < sortedMatches.Count; ++i)
            {
                if (ConsecutiveMatchesAreLongerThanTheQuery(queryLength, sortedMatches, i, configuration))
                {
                    // potentialy a new start of best matched sequence
                    curMinI = i;
                }

                if (i - curMinI > maxLength)
                {
                    maxLength = i - curMinI;
                    maxI      = i;
                    minI      = curMinI;
                }
            }

            double notCovered = 0d;

            for (int i = minI + 1; i <= maxI; ++i)
            {
                if (sortedMatches[i].SubFingerprint.SequenceAt - sortedMatches[i - 1].SubFingerprint.SequenceAt > configuration.FingerprintLengthInSeconds)
                {
                    notCovered += sortedMatches[i].SubFingerprint.SequenceAt - (sortedMatches[i - 1].SubFingerprint.SequenceAt + configuration.FingerprintLengthInSeconds);
                }
            }

            double sourceMatchLength = SubFingerprintsToSeconds.AdjustLengthToSeconds(
                sortedMatches[maxI].SubFingerprint.SequenceAt,
                sortedMatches[minI].SubFingerprint.SequenceAt,
                configuration) - notCovered;

            double sourceMatchStartsAt = sortedMatches[minI].HashedFingerprint.StartsAt;
            double originMatchStartsAt = sortedMatches[minI].SubFingerprint.SequenceAt;

            return(new Coverage(sourceMatchStartsAt, sourceMatchLength, originMatchStartsAt));
        }
Ejemplo n.º 3
0
        public Coverage GetCoverage(IEnumerable <MatchedWith> matches, double queryLength, double fingerprintLengthIsSeconds)
        {
            var orderedByResultAt = matches.OrderBy(with => with.ResultAt).ToList();

            var trackRegion = CoverageEstimator.EstimateTrackCoverage(orderedByResultAt, queryLength, fingerprintLengthIsSeconds);

            var notCovered = GetNotCoveredLength(orderedByResultAt, trackRegion, fingerprintLengthIsSeconds, out var bestMatch);

            // optimistic coverage length
            double sourceCoverageLength = SubFingerprintsToSeconds.AdjustLengthToSeconds(orderedByResultAt[trackRegion.EndAt].ResultAt, orderedByResultAt[trackRegion.StartAt].ResultAt, fingerprintLengthIsSeconds);

            // calculated coverage length
            double calculated = SubFingerprintsToSeconds.AdjustLengthToSeconds(orderedByResultAt[trackRegion.EndAt].ResultAt, orderedByResultAt[trackRegion.StartAt].ResultAt, fingerprintLengthIsSeconds);

            double sourceMatchLength = calculated - notCovered; // exact length of matched fingerprints

            double sourceMatchStartsAt = orderedByResultAt[trackRegion.StartAt].QueryAt;
            double originMatchStartsAt = orderedByResultAt[trackRegion.StartAt].ResultAt;

            return(new Coverage(sourceMatchStartsAt, sourceMatchLength, sourceCoverageLength, originMatchStartsAt, GetTrackStartsAt(bestMatch), queryLength));
        }
Ejemplo n.º 4
0
 private static bool ConsecutiveMatchesAreLongerThanTheQuery(double queryLength, List <MatchedWith> sortedMatches, int index, double fingerprintLengthInSeconds)
 {
     return(SubFingerprintsToSeconds.AdjustLengthToSeconds(sortedMatches[index].ResultAt, sortedMatches[index - 1].ResultAt, fingerprintLengthInSeconds) > queryLength);
 }