overlap

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2020 License: BSD-2-Clause Imports: 7 Imported by: 0

README

overlap

GoDoc Build Status

overlap is a library for identifying overlaps on a list of segments.

Motivation

You are given a list of segments that looks like this:

You are asked to identify any overlaps that are longer than m, or which have at least n segments overlapping.

This package allows you to do that, and identify, for instance, an overlap that is longer than 2 years and has at least 100 segments.

Installation

$ go get github.com/kchristidis/overlap

Usage

results, _ := overlap.Calculate("segments.csv", True)
f, _ := os.Create("overlaps.csv")
defer f.Close()
w := csv.NewWriter(f)
w.WriteAll(results) // calls Flush internally

You can also study the sample binary provided in cmd/overlap, or read the package documentation in GoDoc.

Contributing

Contributions are welcome. Fork this library and submit a pull request.

Documentation

Overview

Package overlap identifies overlaps on a list of segments.

A segment is defined by the tuple:

segment_id, segment_start, segment_end

segment_start and segment_end mark the beginning and the end of the segment on the x-axis.

An overlap between two or more segments is defined by the tuple:

overlap_length, overlap_start, overlap_end, segment_count, segment_list

overlap_length is the length of the overlapping segment, expressed in the same units as segment_start and segment_end. overlap_start and overlap_end mark the beginning and the end of the overlapping segment. segment_count is the number of segments crossing over the overlap; segment_list carries the comma-separated list of all segment_id's crossing over the overlap.

This package then reads a comma-separated values (CSV) file, where each CSV record identifies a segment. It produces a CSV file with all the identified overlaps, one overlap per CSV record.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calculate

func Calculate(filePath string, hasHeaders bool) (results [][]string, err error)

Calculate reads a CSV file with segments (filePath) and returns a list of all of their overlaps (results).

Each CSV record in filePath should identify a segment and consist of exactly three fields:

segment_id(string),segment_start(float64),segment_end(float64)

The type of each field is included in parentheses.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL