-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option -r to reroot outgroup + added command collapse single
- Loading branch information
1 parent
2bb638d
commit 793f532
Showing
10 changed files
with
262 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/fredericlemoine/gotree/io" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// collapseCmd represents the collapse command | ||
var collapsesingleCmd = &cobra.Command{ | ||
Use: "single", | ||
Short: "Collapse branches that connect single nodes", | ||
Long: `Collapse branches that connect single nodes. | ||
Single nodes are defined as nodes that: | ||
- Connect only 2 neighbors | ||
- Are not the root | ||
* Branch lengths are added | ||
* Max branch support is assigned to remaining branch | ||
Ex: | ||
t1 t1 | ||
/ / | ||
n0--n1--n2 => n0--n2 | ||
\ \ | ||
t2 t2 | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
f := openWriteFile(outtreefile) | ||
treefile, treechan := readTrees(intreefile) | ||
defer treefile.Close() | ||
for t := range treechan { | ||
if t.Err != nil { | ||
io.ExitWithMessage(t.Err) | ||
} | ||
t.Tree.RemoveSingleNodes() | ||
f.WriteString(t.Tree.Newick() + "\n") | ||
} | ||
f.Close() | ||
}, | ||
} | ||
|
||
func init() { | ||
collapseCmd.AddCommand(collapsesingleCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.