yukiregista / ConsensusProj

MIT License
2 stars 0 forks source link

テストケースをいくつか作ってPythonと一致するかテスト #62

Open yukiregista opened 1 week ago

yukiregista commented 1 week ago

c_pruneSTD_greedy_pruning の結果が一致するかのテスト。

二つの木が一致しているかどうか見るには、例えば src/booster/pysrc/test_equivalent.pyのコードを参考にしてください(t1_datat2_data を対象のnewick string にすれば動くと思います)

(検証してないですが)次のような感じで二つのバージョンの木が得られます:

import Consensus
import dendropy

init_file = /path/to/init/file
input_file = /path/to/input/trees/file

# c version
newick_c = Consensus.c_prune(inittree_file=init_file, inputtrees_file=input_file, K=20) # newick file

# python version
init_tree = Consensus.Tree_with_support.get(path = init_file, schema="newick")
input_trees  = Consensus.TreeList_with_support.get(path = input_file, schema="newick", taxon_namespace=init_tree.taxon_namespace)
pruned_tree = init_tree.STD_greedy_pruning(input_trees)

# comparison
c_pruned = Consensus.Tree_with_support.get(data = newick_c, schema="newick", taxon_namespace=pruned_tree.taxon_namespace)
fp, fn = dendropy.calculate.treecompare.false_positives_and_negatives(pruned_tree,c_pruned)
print(fp,fn)

同様に、unscaled versionも c_prune(..., scaled=False), init_tree.SUTD_greedy_pruning(input_trees) も比較してもらえると助かります。

yukiregista commented 3 days ago

すいません、test_equivalent.py はサポートが一致しているか見るために作ったものでした... 同じ木であるかどうかだけ興味が一旦あるので、RF距離が0であれば良いです。dendropy.calculate.treecompare.false_positives_and_negatives(t1,t2) みたいな感じで実行して、(0,0)が帰ってくればokです。