Ich habe folgendes Problem. Mit Biopython möchte ich eine Baum-Struktur einlesen (Stammbaum). Der Baum wird, wenn man sich an die Biopython-Doku hält, als <class 'Bio.Phylo.Newick.Tree'> verfügbar gemacht. Das Problem ist nun, dass man davon keine unabhängige Kopie machen kann (#2). In #3 verändere ich den Baum; leider ist davon auch das Backup (#4) betroffen. Ich habe in #2 also nur so was wie einen Zeiger erzeugt und keine unabhänige Kopie. Weiß jemand Rat?
Danke!
Code: Alles auswählen
from Bio import Phylo
import sys
#1 read tree with BioPython
tree = Phylo.read(sys.argv[1], 'newick') #<class 'Bio.Phylo.Newick.Tree'>
#2 copy?
backup = tree
#3 modifications
for clade in tree.find_clades():
clade.name = "fubar"
#4 problem: backup is fubar
for clade in backup.find_clades():
print clade.name #'fubar'