Not every marker is followed by associated segment
500753
private static boolean doesMarkerStartSegment(int markerSecondByte) {
    if (markerSecondByte == JfifUtil.MARKER_TEM) {
      return false;
    }

    if (markerSecondByte >= JfifUtil.MARKER_RST0 && markerSecondByte <= JfifUtil.MARKER_RST7) {
      return false;
    }

    return markerSecondByte != JfifUtil.MARKER_EOI && markerSecondByte != JfifUtil.MARKER_SOI;
  }
1113271
function matchSegment(ax, ay, bx, by, cx, cy, dx, dy, r, result) {
    var len = result.length;

    var ap = closePoint(ax, ay, cx, cy, dx, dy, r);
    var bp = closePoint(bx, by, cx, cy, dx, dy, r);

    //     a----b
    // c---ap---bp---d
    if (ap !== null && bp !== null) return true; // fully covered

    var cp = closePoint(cx, cy, ax, ay, bx, by, r);
    var dp = closePoint(dx, dy, ax, ay, bx, by, r);

    if (cp !== null && cp === dp) return false; // degenerate case, no overlap

    var cpx, cpy, dpx, dpy;
    if (cp !== null) {
        cpx = interp(ax, bx, cp);
        cpy = interp(ay, by, cp);
    }
    if (dp !== null) {
        dpx = interp(ax, bx, dp);
        dpy = interp(ay, by, dp);
    }

    if (cp !== null && dp !== null) {

        if (cpx === dpx && cpy === dpy) return false; // degenerate case

        // a---cp---dp---b
        //     c----d
        if (cp < dp) {
            if (!equals(ax, ay, cpx, cpy)) addSegment(result, ax, ay, cpx, cpy);
            if (!equals(dpx, dpy, bx, by)) addSegment(result, dpx, dpy, bx, by);

        // a---dp---cp---b
        //     d----c
        } else {
            if (!equals(ax, ay, dpx, dpy)) addSegment(result, ax, ay, dpx, dpy);
            if (!equals(cpx, cpy, bx, by)) addSegment(result, cpx, cpy, bx, by);
        }

    } else if (cp !== null) {
        //     a----cp---b
        // d---ap---c
        if (ap !== null && !equals(ax, ay, cpx, cpy)) addSegment(result, cpx, cpy, bx, by);

        // a---cp---b
        //     c----bp---d
        else if (bp !== null && !equals(cpx, cpy, bx, by)) addSegment(result, ax, ay, cpx, cpy);

    } else if (dp !== null) {
        // a---dp---b
        //     d----bp---c
        if (bp !== null && !equals(dpx, dpy, bx, by)) addSegment(result, ax, ay, dpx, dpy);

        //     a----dp---b
        // c---ap---d
        else if (ap !== null && !equals(ax, ay, dpx, dpy)) addSegment(result, dpx, dpy, bx, by);
    }

    return result.length !== len; // segment processed
}
330890
private static final int marker(int marker) {
        for (int i = 0; i < VALID_MARKERS.length; i++) {
            if (marker == VALID_MARKERS[i]) {
                return VALID_MARKER;
            }
        }
        for (int i = 0; i < NOPARAM_MARKERS.length; i++) {
            if (marker == NOPARAM_MARKERS[i]) {
                return NOPARAM_MARKER;
            }
        }
        for (int i = 0; i < UNSUPPORTED_MARKERS.length; i++) {
            if (marker == UNSUPPORTED_MARKERS[i]) {
                return UNSUPPORTED_MARKER;
            }
        }
        return NOT_A_MARKER;
    }
34723
def identify_assembly_points(graph, bgtree, target_multicolor, exclude=None, verbose=False, verbose_destination=None):
    
    if verbose:
        print(">>Identifying assemblies for target multicolor:",
              [e.name for e in target_multicolor.multicolors.elements()], file=verbose_destination)

    guidance = bgtree.consistent_multicolors[:]
    offset = len(Multicolor.split_colors(target_multicolor, guidance=guidance,
                                         account_for_color_multiplicity_in_guidance=False)) - 1

    threshold = 1 if offset == 0 else 2
    assemblies = []  # the overall result
    if exclude is None:
        exclude = []  # a container with single colors of genomes, that are to be considered fully assembled

    p_t_consistent_multicolors_in_target = Multicolor.split_colors(target_multicolor, guidance=guidance,
                                                                   account_for_color_multiplicity_in_guidance=False)
    t_consistent_multicolors_in_target = []
    for tcmc in p_t_consistent_multicolors_in_target:
        t_consistent_multicolors_in_target.append(sorted(color.name for color in tcmc.colors))
    # we work with each connected component separately, as connected components usually preserve fragmentation points
    ################################################################################################
    #
    # its important that we iterate over connected components making each particular one a deepcopy of an
    #   underlying breakpoint graph connected component
    #
    ################################################################################################
    for i, cc in enumerate(graph.connected_components_subgraphs(copy=True)):

        # we filter current connected component of uninteresting / ambiguous edges and retrieve a list of
        #   connected components that are left in the original connected components after filtration
        irregular_subnets = get_irregular_subnets(cc, target_multicolor, exclude)

        if len(irregular_subnets) > 0 and verbose:
            print(">>Processing", str(i) + "th", "connected component", file=verbose_destination)
            print("\tcontains", len(irregular_subnets), "subnet groups", file=verbose_destination)

        # each subnet can be processed separately
        for subnet in irregular_subnets:

            supporting_edge_scores = get_support_edge_scores(graph, subnet, target_multicolor, bgtree)

            # we create a new dummy graph for the purpose of computing maximum weight matching for support edges in it
            new_graph = nx.Graph()
            if verbose:
                print("\tcontains", len(supporting_edge_scores), "possible assembly points", file=verbose_destination)

            # we'll keep track of possible assembly points for future reference
            support_edge_dict = {}
            for (v1, v2), before, after, ex_data in supporting_edge_scores:
                ex_data["tcmc"] = t_consistent_multicolors_in_target
                ##########################################################################################
                #
                # INSERT YOUR CODE ASSEMBLY SCORE THRESHOLD FILTRATION HERE IF NEED BE
                #
                ##########################################################################################
                if before - after - offset < threshold:
                    continue
                ##########################################################################################
                #
                # by default networkx assumes all edges, that have weight >= 0 are good
                #
                ##########################################################################################
                new_graph.add_edge(v1, v2, weight=before - after - offset)
                support_edge_dict[(v1, v2)] = (before, after + offset, ex_data)
                support_edge_dict[(v2, v1)] = (before, after + offset, ex_data)

            maximal_matching = nx.max_weight_matching(new_graph)

            if verbose:
                print("\t", len(maximal_matching) // 2, "assembly points are identified", file=verbose_destination)

            # as networkx provides a maximum matching in a form of adjacency list, every identified edge
            #   (pair of vertices) is present their twice (i.e. matching[v1]=v2 and matching[v2]=v1)
            #   we need to make sure we only add every edge only once
            visited = set()
            for v1, v2 in maximal_matching.items():
                if v1 in visited or v2 in visited:
                    continue
                visited.add(v1)
                visited.add(v2)
                assemblies.append((v1, v2, support_edge_dict[(v1, v2)]))

    # we return the result as a list of assembly points that were identified for the targeted multicolor
    # as a list of tuples (v1, v2, ("before", "after"))
    # where v1 and v2 correspond to assembly point and "before" and "after" are used to compute the assembly score
    return assemblies
884348
def n_segments(neurites, neurite_type=NeuriteType.all):
    ''''''
    return sum(len(s.points) - 1
               for s in iter_sections(neurites, neurite_filter=is_type(neurite_type)))
567935
def postprocess_segments(self):
        """"""
        # make segs a list of mask arrays, it's easier to store
        # as there is a hdf5 equivalent
        for iseg, seg in enumerate(self.segs):
            mask = np.zeros(self._adata.shape[0], dtype=bool)
            mask[seg] = True
            self.segs[iseg] = mask
        # convert to arrays
        self.segs = np.array(self.segs)
        self.segs_tips = np.array(self.segs_tips)
747348
function PixelWalker(firstPoint, pixel_path) {

    // go clockwise starting first point
    var points = [];
    points.push(firstPoint);

    var moveHorizontal = true;	// alternate horizontal and vertical movements to form pixel heart

    pixel_path.forEach(function (p) {

        var previous_point = points[points.length - 1];
        var point_to_add;

        if (moveHorizontal) {
            point_to_add = [p, 0];
        } else {
            point_to_add = [0, p];
        }
        var e = makerjs.point.add(previous_point, point_to_add);
        points.push(e);

        // flip direction each time
        moveHorizontal = !moveHorizontal;
    });

    return points;
}
374330
private void  marker(Attributes attributes) throws SVGParseException
   {
      debug("<marker>");

      if (currentElement == null)
         throw new SVGParseException("Invalid document. Root element must be <svg>");
      SVG.Marker  obj = new SVG.Marker();
      obj.document = svgDocument;
      obj.parent = currentElement;
      parseAttributesCore(obj, attributes);
      parseAttributesStyle(obj, attributes);
      parseAttributesConditional(obj, attributes);
      parseAttributesViewBox(obj, attributes);
      parseAttributesMarker(obj, attributes);
      currentElement.addChild(obj);
      currentElement = obj;
   }
948697
private void interiorLineInteriorLine_(int half_edge, int id_a, int id_b,
			int cluster_index_a, int cluster_index_b) {
		if (m_matrix[MatrixPredicate.InteriorInterior] == 1)
			return;

		int parentage = m_topo_graph.getHalfEdgeParentage(half_edge);

		if ((parentage & id_a) != 0 && (parentage & id_b) != 0) {
			m_matrix[MatrixPredicate.InteriorInterior] = 1;
			return;
		}

		if (m_matrix[MatrixPredicate.InteriorInterior] != 0) {
			if (m_topo_graph.getHalfEdgeUserIndex(m_topo_graph
					.getHalfEdgePrev(m_topo_graph.getHalfEdgeTwin(half_edge)),
					m_visited_index) != 1) {
				int cluster = m_topo_graph.getHalfEdgeTo(half_edge);
				int clusterParentage = m_topo_graph
						.getClusterParentage(cluster);

				if ((clusterParentage & id_a) != 0
						&& (clusterParentage & id_b) != 0) {
					int index_a = m_topo_graph.getClusterUserIndex(cluster,
							cluster_index_a);
					int index_b = m_topo_graph.getClusterUserIndex(cluster,
							cluster_index_b);
					assert (index_a != -1);
					assert (index_b != -1);

					if ((index_a % 2 == 0) && (index_b % 2 == 0)) {
						assert ((m_topo_graph.getClusterParentage(cluster) & id_a) != 0 && (m_topo_graph
								.getClusterParentage(cluster) & id_b) != 0);
						m_matrix[MatrixPredicate.InteriorInterior] = 0;
					}
				}
			}
		}
	}
1368515
function(segments) {
        var previousSegment = [-1, -1];
        var segmentIndicesToRemove = [];
        var cleanedSegmentArray = [];
        var i, ii;
        for (i = 0, ii = segments.length; i < ii; ++i) {
            if (!(previousSegment[0] <= segments[i][0] &&
                    previousSegment[1] >= segments[i][1])) {
                cleanedSegmentArray.push(segments[i]);
            }
            previousSegment = segments[i];
        }

        segments.length = 0;
        for (i = 0, ii = cleanedSegmentArray.length; i < ii; ++i) {
            segments.push(cleanedSegmentArray[i]);
        }
    }
671976
def _marker_line(self):
        # type: () -> str
        
        output = ''
        for col in sorted(self.col_widths):
            line = self.COLUMN_MARK + (self.DASH * (self.col_widths[col] + self.PADDING * 2))
            output += line
        output += self.COLUMN_MARK + '\n'

        return output
397932
function skipMarker(state, line) {
    var pos, marker,
        start = state.bMarks[line] + state.tShift[line],
        max = state.eMarks[line];

    if (start >= max) { return -1; }

    // Check bullet
    marker = state.src.charCodeAt(start++);
    if (marker !== 0x7E/* ~ */ && marker !== 0x3A/* : */) { return -1; }

    pos = state.skipSpaces(start);

    // require space after ":"
    if (start === pos) { return -1; }

    // no empty definitions, e.g. "  : "
    if (pos >= max) { return -1; }

    return start;
  }
1141672
public static void addMarkerAsPolygon(Marker marker, List<Marker> markers) {
        LatLng position = marker.getPosition();
        int insertLocation = markers.size();
        if (markers.size() > 2) {
            double[] distances = new double[markers.size()];
            insertLocation = 0;
            distances[0] = SphericalUtil.computeDistanceBetween(position,
                    markers.get(0).getPosition());
            for (int i = 1; i < markers.size(); i++) {
                distances[i] = SphericalUtil.computeDistanceBetween(position,
                        markers.get(i).getPosition());
                if (distances[i] < distances[insertLocation]) {
                    insertLocation = i;
                }
            }

            int beforeLocation = insertLocation > 0 ? insertLocation - 1
                    : distances.length - 1;
            int afterLocation = insertLocation < distances.length - 1 ? insertLocation + 1
                    : 0;

            if (distances[beforeLocation] > distances[afterLocation]) {
                insertLocation = afterLocation;
            }

        }
        markers.add(insertLocation, marker);
    }
1276336
def _identify_heterogeneity_blocks_seg(in_file, seg_file, params, work_dir, somatic_info):
    
    def _segment_by_cns(target_chrom, freqs, coords):
        with open(seg_file) as in_handle:
            reader = csv.reader(in_handle, dialect="excel-tab")
            next(reader)  # header
            for cur_chrom, start, end in (xs[:3] for xs in reader):
                if cur_chrom == target_chrom:
                    block_freqs = []
                    for i, (freq, coord) in enumerate(zip(freqs, coords)):
                        if coord >= int(start) and coord < int(end):
                            block_freqs.append(freq)
                        elif coord >= int(end):
                            break
                    coords = coords[max(0, i - 1):]
                    freqs = freqs[max(0, i - 1):]
                    if len(block_freqs) > params["hetblock"]["min_alleles"]:
                        yield start, end
    return _identify_heterogeneity_blocks_shared(in_file, _segment_by_cns, params, work_dir, somatic_info)
1025119
def map_segments(func, neurites, neurite_type):
    ''' 
    '''
    neurite_filter = is_type(neurite_type)
    return [
        s for ss in iter_sections(neurites, neurite_filter=neurite_filter) for s in func(ss)
    ]
1177411
function preprocessMatchPath(segments) {
    const merged = mergeConsecutive(segments, '**');
    if (merged.length !== segments.length) {
        warn(`Consecutive '**' globs found
              (${segments.length - merged.length} excess).`);
    }
    segments = isolateGlobstarPattern(segments);
    segments = appendGlobstarIfTrailingSlash(segments);
    return mergeConsecutive([ ...segments,
                              ...(last(segments) === '**' ? ['*'] : []) ],
                            '**');
}
1096686
private void findMarkers(String url, String target) {
        final char[] data = url.toCharArray();

        // we only care about the last path segment so find that first
        int i = 0;
        int lastSlash = 0;
        for (; i < data.length; i++) {
            if ('/' == data[i]) {
                lastSlash = i;
            } else if ('?' == data[i]) {
                this.queryMarker = i;
                break; // out of loop since query data is after the path
            }
        }
        // now check for the id marker and/or fragments for the last segment
        for (i = lastSlash; i < data.length; i++) {
            if (i == this.queryMarker) {
                // no fragments or segment parameters were found
                break;
            } else if ('#' == data[i]) {
                // found a "#fragment" at the end of the path segment
                this.fragmentMarker = i;
                break;
            } else if (';' == data[i]) {
                // found a segment parameter block (would appear before the
                // optional fragment or query data)
                this.paramMarker = i;
                if (url.regionMatches(i, target, 0, target.length())) {
                    this.idMarker = i;
                }
            }
        }
    }