prep

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package used for preprocessing necessary data for the CAMUS algorithm

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFile     = errors.New("invalid file")
	ErrInvalidFormat   = errors.New("invalid format")
	ErrNoReticulations = errors.New("no reticulations")
	ErrWritingFile     = errors.New("error writing file")
)
View Source
var (
	ErrUnrooted     = errors.New("not rooted")
	ErrNonBinary    = errors.New("not binary")
	ErrMulTree      = errors.New("contains duplicate labels")
	ErrTypeOutRange = errors.New("out of type range")
)
View Source
var ParseFormat = map[string]Format{
	"newick": Newick,
	"nexus":  Nexus,
}

Functions

func ConvertToNetwork

func ConvertToNetwork(ntw *tree.Tree) (network *gr.Network, err error)

Read in extended newick file and make network

func NetworkIsBinary

func NetworkIsBinary(ntw *tree.Tree) bool

func Preprocess

func Preprocess(tre *tree.Tree, geneTrees []*tree.Tree, nprocs int, opts QuartetFilterOptions, minSupp float64) (*gr.TreeData, error)

Preprocess necessary data. Returns an error if the constraint tree is not valid (e.g., not rooted/binary) or if the gene trees are not valid (bad leaf labels).

func TreeIsBinary

func TreeIsBinary(tre *tree.Tree) bool

func WriteDPResultsToCSV added in v0.8.0

func WriteDPResultsToCSV(td *gr.TreeData, newicks []string, qsat []float64, w io.Writer) (err error)

Write DP results csv file to writer.

There are three columns: "Number of Branches", "Quartet Satisfied Percent", "Extended Newick"

func WriteResultsLineplot added in v0.8.0

func WriteResultsLineplot(qstat []float64, prefix string) error

func WriteRetScoresToCSV

func WriteRetScoresToCSV(scores []*map[string]float64, names []string) error

Write csv file containing reticulation branch scores to stdout

Types

type Format

type Format int
const (
	Newick Format = iota
	Nexus
)

func (*Format) Set

func (f *Format) Set(s string) error

func (Format) String

func (f Format) String() string

type GeneTrees

type GeneTrees struct {
	Trees []*tree.Tree // gene trees
	Names []string     // gene names
}

func ReadInputFiles

func ReadInputFiles(treeFile, genetreesFile string, format Format) (*tree.Tree, *GeneTrees, error)

Reads in and validates constraint tree and gene tree input files. Returns an error if the newick format is invalid, or the file is invalid for some other reason (e.g., more than one constraint tree)

type QMode

type QMode int
const (
	NonRestrictive QMode = iota + 1
	Restrictive
)

func (*QMode) Set

func (mode *QMode) Set(n int) error

func (QMode) String

func (mode QMode) String() string

type QuartetFilterOptions added in v0.4.1

type QuartetFilterOptions struct {
	// contains filtered or unexported fields
}

Options for quartet filter mode

func SetQuartetFilterOptions added in v0.4.1

func SetQuartetFilterOptions(mode int, threshold float64) (QuartetFilterOptions, error)

func (QuartetFilterOptions) QuartetFilterOff added in v0.4.1

func (opts QuartetFilterOptions) QuartetFilterOff() bool

type Threshold added in v0.4.1

type Threshold float64

func (Threshold) Keep added in v0.4.1

func (thresh Threshold) Keep(counts []uint32) bool

func (*Threshold) Set added in v0.4.1

func (thresh *Threshold) Set(n float64) error

func (Threshold) String added in v0.4.1

func (thresh Threshold) String() string

Jump to

Keyboard shortcuts

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