def newTreeInProject(self, treename, treefile, projectTitle, treetype):
     import phyloimport_algorithm, root_phylotree_algorithm
     collectionName = self.returnCollectionForObjectByName(
         projectTitle, 'PhyloTree', treename)
     #collectionName = self.prefixString+projectTitle+self.separatorString+"PhyloTree"+self.separatorString+treename
     treeCollection = self.db[collectionName]
     print "uploading tree to collection: ", collectionName
     print "treetype is: ", treetype
     # create the new collection in mongo for this tree
     trees = Phylo.parse(treefile, treetype)
     #print "length of trees list: ",len(trees)
     for tree in trees:
         #process tree
         phyloimport_algorithm.recursive_clade(tree, treeCollection)
         root_phylotree_algorithm.addRootToTree(treeCollection)
         # add a tree record entry to the 'PyloTree' array in the project record
         self.db[self.projectCollectionName].update(
             {"name": projectTitle},
             {'$push': {
                 u'PhyloTree': {
                     treename: treefile
                 }
             }})
         self.db[self.projectCollectionName].update(
             {"name": projectTitle},
             {'$addToSet': {
                 u'datatypes': u'PhyloTree'
             }})
    def newTreeInProjectFromString(self,treename,treestring,projectTitle, description,treetype):
        import phyloimport_algorithm, root_phylotree_algorithm

        collectionName = self.prefixString+projectTitle+self.separatorString+"PhyloTree"+self.separatorString+treename
        treeCollection = self.db[collectionName]
        treeCollection.drop()
        print "uploading tree to collection: ",collectionName
        print "treetype is: ",treetype

        # if the project does not exist, create it
        projectCollectionName = self.prefixString + 'projects'
        if self.db[projectCollectionName].find_one({"name": projectTitle}) == None:
            self.newProject(projectTitle)

        # create the new collection in mongo for this tree.  The tree is encoded
        # in a string, so it needs to be processed slightly different than from a file
        from StringIO import StringIO
        handle = StringIO(treestring)
        trees = Phylo.parse(handle, treetype)
        #print "length of trees list: ",len(trees)
        for tree in trees:
            phyloimport_algorithm.recursive_clade(tree, treeCollection)
            # add a tree record entry to the 'PyloTree' array in the project record
            self.db[self.projectCollectionName].update({"name": projectTitle}, { '$push': {u'PhyloTree': {treename:str(description)}}})
            self.db[self.projectCollectionName].update({"name": projectTitle}, { '$addToSet': {u'datatypes': u'PhyloTree'}})
            # make sure the tree is rooted, so viewers work
            root_phylotree_algorithm.addRootToTree(treeCollection)

            # emit a signal so the GUI knows to update
            if (self.QtGuiEnabled):
                self.datatypeListChangedSignal.emit();
                self.datasetListChangedSignal.emit();
 def newTreeInProject(self,treename,treefile,projectTitle, treetype):
     import phyloimport_algorithm, root_phylotree_algorithm
     collectionName = self.returnCollectionForObjectByName(projectTitle, 'PhyloTree', treename)
     #collectionName = self.prefixString+projectTitle+self.separatorString+"PhyloTree"+self.separatorString+treename
     treeCollection = self.db[collectionName]
     print "uploading tree to collection: ",collectionName
     print "treetype is: ",treetype
     # create the new collection in mongo for this tree
     trees = Phylo.parse(treefile, treetype)
     #print "length of trees list: ",len(trees)
     for tree in trees:
         #process tree
         phyloimport_algorithm.recursive_clade(tree, treeCollection)
         root_phylotree_algorithm.addRootToTree(treeCollection)
         # add a tree record entry to the 'PyloTree' array in the project record
         self.db[self.projectCollectionName].update({"name": projectTitle}, { '$push': {u'PhyloTree': {treename:treefile}}})
         self.db[self.projectCollectionName].update({"name": projectTitle}, { '$addToSet': {u'datatypes': u'PhyloTree'}})
    def newTreeInProject(self,treename,treefile,projectTitle, treetype):
        collectionName = self.prefixString+projectTitle+"_"+"PhyloTree"+"_"+treename
        treeCollection = self.db[collectionName]
        print "uploading tree to collection: ",collectionName
        print "treetype is: ",treetype
        # create the new collection in mongo for this tree
        trees = Phylo.parse(treefile, treetype)
        #print "length of trees list: ",len(trees)
        for tree in trees:
            #process tree
            phyloimport_algorithm.recursive_clade(tree, treeCollection)
            # add a tree record entry to the 'PyloTree' array in the project record
            self.db.ar_projects.update({"name": projectTitle}, { '$push': {u'PhyloTree': {treename:treefile}}})
            self.db.ar_projects.update({"name": projectTitle}, { '$addToSet': {u'datatypes': u'PhyloTree'}})

        # emit a signal so the GUI knows to update
        self.datatypeListChangedSignal.emit(); 
        self.datasetListChangedSignal.emit();               
    def newTreeInProjectFromString(self, treename, treestring, projectTitle,
                                   description, treetype):
        import phyloimport_algorithm, root_phylotree_algorithm

        collectionName = self.prefixString + projectTitle + self.separatorString + "PhyloTree" + self.separatorString + treename
        treeCollection = self.db[collectionName]
        treeCollection.drop()
        print "uploading tree to collection: ", collectionName
        print "treetype is: ", treetype

        # if the project does not exist, create it
        projectCollectionName = self.prefixString + 'projects'
        if self.db[projectCollectionName].find_one({"name":
                                                    projectTitle}) == None:
            self.newProject(projectTitle)

        # create the new collection in mongo for this tree.  The tree is encoded
        # in a string, so it needs to be processed slightly different than from a file
        from StringIO import StringIO
        handle = StringIO(treestring)
        trees = Phylo.parse(handle, treetype)
        #print "length of trees list: ",len(trees)
        for tree in trees:
            phyloimport_algorithm.recursive_clade(tree, treeCollection)
            # add a tree record entry to the 'PyloTree' array in the project record
            self.db[self.projectCollectionName].update(
                {"name": projectTitle},
                {'$push': {
                    u'PhyloTree': {
                        treename: str(description)
                    }
                }})
            self.db[self.projectCollectionName].update(
                {"name": projectTitle},
                {'$addToSet': {
                    u'datatypes': u'PhyloTree'
                }})
            # make sure the tree is rooted, so viewers work
            root_phylotree_algorithm.addRootToTree(treeCollection)

            # emit a signal so the GUI knows to update
            if (self.QtGuiEnabled):
                self.datatypeListChangedSignal.emit()
                self.datasetListChangedSignal.emit()
 def newTreeInProjectFromString(self,treename,treestring,projectTitle, description,treetype):
     collectionName = self.prefixString+projectTitle+"_"+"PhyloTree"+"_"+treename
     treeCollection = self.db[collectionName]
     print "uploading tree to collection: ",collectionName
     print "treetype is: ",treetype
     # create the new collection in mongo for this tree.  The tree is encoded 
     # in a string, so it needs to be processed slightly different than from a file
     from StringIO import StringIO
     handle = StringIO(treestring)
     trees = Phylo.parse(handle, treetype)
     #print "length of trees list: ",len(trees)
     for tree in trees:
         phyloimport_algorithm.recursive_clade(tree, treeCollection)
         # add a tree record entry to the 'PyloTree' array in the project record
         self.db.ar_projects.update({"name": projectTitle}, { '$push': {u'PhyloTree': {treename:str(description)}}})
         self.db.ar_projects.update({"name": projectTitle}, { '$addToSet': {u'datatypes': u'PhyloTree'}})
         # make sure the tree is rooted, so viewers work
         root_phylotree_algorithm.addRootToTree(treeCollection)
         # emit a signal so the GUI knows to update
         self.datatypeListChangedSignal.emit(); 
         self.datasetListChangedSignal.emit();