Skip to content

Commit

Permalink
[extract] Add label column to pairs.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Sep 3, 2018
1 parent c42f43a commit c36c4f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type ContigPair struct {
L1, L2 int
nObservedLinks int
nExpectedLinks float64
label string // allelic/cross-allelic/ok
}

// String outputs the string representation of ContigInfo
Expand All @@ -73,9 +74,9 @@ func (r ContigInfo) String() string {

// String outputs the string representation of ContigInfo
func (r ContigPair) String() string {
return fmt.Sprintf("%d\t%d\t%s\t%s\t%d\t%d\t%d\t%.1f",
return fmt.Sprintf("%d\t%d\t%s\t%s\t%d\t%d\t%d\t%.1f\t%s",
r.ai, r.bi, r.at, r.bt, r.RE1, r.RE2,
r.nObservedLinks, r.nExpectedLinks)
r.nObservedLinks, r.nExpectedLinks, r.label)
}

// uintLog2 calculates the integer log2 of a number
Expand Down Expand Up @@ -241,7 +242,7 @@ func (r *Extracter) calcInterContigs() {
L1, L2 := ca.length, cb.length
cp = &ContigPair{ai: ai, bi: bi, at: at, bt: bt,
RE1: ca.recounts, RE2: cb.recounts,
L1: L1, L2: L2}
L1: L1, L2: L2, label: "ok"}
cp.nExpectedLinks = sumf(r.findExpectedInterContigLinks(0, L1, L2))
cp.nObservedLinks = len(line.links)
contigPairs[pair] = cp
Expand All @@ -253,7 +254,7 @@ func (r *Extracter) calcInterContigs() {
f, _ := os.Create(outfile)
w := bufio.NewWriter(f)
defer f.Close()
fmt.Fprintf(w, "#X\tY\tContig1\tContig2\tRE1\tRE2\tObservedLinks\tExpectedLinksIfAdjacent\n")
fmt.Fprintf(w, "#X\tY\tContig1\tContig2\tRE1\tRE2\tObservedLinks\tExpectedLinksIfAdjacent\tLabel\n")

allPairs := []*ContigPair{}
for _, c := range contigPairs {
Expand Down
2 changes: 2 additions & 0 deletions partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,14 @@ func parseDist(pairsFile string) []ContigPair {
RE2, _ := strconv.Atoi(rec[5])
nObservedLinks, _ := strconv.Atoi(rec[6])
nExpectedLinks, _ := strconv.ParseFloat(rec[7], 64)
label := rec[8]

cp := ContigPair{
ai: ai, bi: bi,
at: at, bt: bt,
RE1: RE1, RE2: RE2,
nObservedLinks: nObservedLinks, nExpectedLinks: nExpectedLinks,
label: label,
}

edges = append(edges, cp)
Expand Down
5 changes: 5 additions & 0 deletions prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ type Pruner struct {
type AlleleGroup []string

// Run calls the pruning steps
// The pruning algorithm is a heuristic method that removes the following pairs:
//
// 1. Alleleic, these are directly the pairs of allelic contigs given in the allele table
// 2. Cross-allelic, these are any contigs that connect to the allelic contigs so we only keep the
// the best pair
func (r *Pruner) Run() {
edges := parseDist(r.PairsFile)
alleleGroups := parseAllelesTable(r.AllelesFile)
Expand Down

0 comments on commit c36c4f4

Please sign in to comment.