Git Product home page Git Product logo

Comments (3)

odannis avatar odannis commented on August 19, 2024 1

Thank you for your answer!

I wrote this little code :

import uuid
from Bio import Phylo
import sys

def modify_clades(clade_root,pos_msa):
    b = clade_root.clades
    if len(b)>0:
        for clade in b:
            clade.name = str(uuid.uuid1())
            modify_clades(clade,pos_msa)
    else:
        clade_root.name = str(pos_msa[0])
        pos_msa[0] += 1

def write_new_tree_for_ccmgen(file_tree, file_new_tree):
    print("Tree used : ", file_tree)
    tree = Phylo.read(file_tree,"newick")
    pos_msa = [0]
    modify_clades(tree.clade, pos_msa)
    tree.clade.name = "root"
    tree.clade.branch_length = 0
    print("New Tree to use : ", file_new_tree)
    tree = Phylo.write(tree,file_new_tree,"newick")

You just have to do : write_new_tree_for_ccmgen(file_tree,file_new_tree)
If anyone want to use it, feel free to do it !

from ccmgen.

odannis avatar odannis commented on August 19, 2024

Link for the file if you want to reproduce the error

from ccmgen.

croth1 avatar croth1 commented on August 19, 2024

Hi @odannis,

CCMgen is a bit restrictive when it comes to the newick format. As you already realised, the root node's label is root, the leaf nodes need to be integers that represent the position in the MSA and the internal nodes have to be named, but the name itself is not of importance. The following would be a valid input to CCMgen. Here the internal nodes were assigned random uuids.

(((0:0.39069,1:0.31737)dbf15fd9-b633-4ef2-ba1b-7a53968eb62d:0.27912,(2:0.40812,3:0.50920)fb32eeb4-513a-4063-ab10-ddbad71e5d78:0.39598)c193ccc3-e1a6-431a-acce-068fa70738a2:0.36127,((4:0.30630,5:0.30630)b9c4a9dd-57e1-4e84-b134-e748b5be9b3a:0.27982,(6:0.51569,7:0.42195)9f60b3ad-ac66-420d-bfe8-394bd2f446ed:0.27956)7c63c71a-cb6c-4c37-869a-326162c9282c:0.11241)root:0.00000;

I feel like the easiest solution is to write a short script that reads in the newick file from fasttree2, reformats it according to these constraints and writes it out again. This should not take more than 10-20 lines of code, I feel.

from ccmgen.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.