Mercurial > repos > jjjjia > cpo_prediction
diff cpo_galaxy_tree.py @ 12:4b2738bc81ed draft
planemo upload
author | jjjjia |
---|---|
date | Fri, 24 Aug 2018 19:10:42 -0400 |
parents | 8aaa4001383b |
children | a14b12a71a53 |
line wrap: on
line diff
--- a/cpo_galaxy_tree.py Fri Aug 24 16:54:25 2018 -0400 +++ b/cpo_galaxy_tree.py Fri Aug 24 19:10:42 2018 -0400 @@ -18,6 +18,7 @@ # <requirement type="package" version="3.6">python</requirement> # <requirement type="package" version="3.1.1">ete3</requirement> # <requirement type="package" version="5.6.0">pyqt</requirement> +# <requirement type="package" version="5.6.2">qt</requirement> # </requirements> import subprocess @@ -53,17 +54,17 @@ class workflowResult(object): def __init__(self): self.new = False - self.ID = "" - self.ExpectedSpecies = "" - self.MLSTSpecies = "" - self.SequenceType = "" - self.MLSTScheme = "" - self.CarbapenemResistanceGenes ="" - self.OtherAMRGenes="" - self.TotalPlasmids = 0 + self.ID = "?" + self.ExpectedSpecies = "?" + self.MLSTSpecies = "?" + self.SequenceType = "?" + self.MLSTScheme = "?" + self.CarbapenemResistanceGenes ="?" + self.OtherAMRGenes="?" + self.TotalPlasmids = -1 self.plasmids = [] - self.DefinitelyPlasmidContigs ="" - self.LikelyPlasmidContigs="" + self.DefinitelyPlasmidContigs ="?" + self.LikelyPlasmidContigs="?" self.row = "" class plasmidObj(object): def __init__(self): @@ -128,13 +129,15 @@ _worflowResult = {} r = pandas.read_csv(pathToResult, delimiter='\t', header=0) r = r.replace(numpy.nan, '', regex=True) + _naResult = workflowResult() + _worflowResult["na"] = _naResult for i in range(len(r.index)): _results = workflowResult() if(str(r.loc[r.index[i], 'new']).lower() == "new"): _results.new = True else: _results.new = False - _results.ID = str(r.loc[r.index[i], 'ID']) + _results.ID = str(r.loc[r.index[i], 'ID']).replace(".fa","") _results.ExpectedSpecies = str(r.loc[r.index[i], 'Expected Species']) _results.MLSTSpecies = str(r.loc[r.index[i], 'MLST Species']) _results.SequenceType = str(r.loc[r.index[i], 'Sequence Type']) @@ -177,7 +180,7 @@ #set the tree style ts = e.TreeStyle() - ts.show_leaf_name = False + ts.show_leaf_name = True ts.show_branch_length = True ts.scale = 2000 #pixel per branch length unit ts.branch_vertical_margin = 15 #pixel between branches @@ -228,10 +231,13 @@ elif (n.is_leaf() and not n.name == "Reference"): #not reference branches, populate with metadata index = 0 - mData = metadata[n.name.replace(".fa","")] + if (n.name.replace(".fa","") in metadata.keys()): + mData = metadata[n.name.replace(".fa","")] + else: + mData = metadata["na"] n.add_face(addFace(mData.ID), index, "aligned") index = index + 1 - if (metadata[n.name.replace(".fa","")].new == True): #new column + if (mData.new == True): #new column face = e.RectFace(30,30,"green","green") # TextFace("Y",fsize=10,tight_text=True) face.border.margin = 5 face.margin_right = 5 @@ -271,4 +277,4 @@ Main() end = time.time() -print("Finished!\nThe analysis used: " + str(end-start) + " seconds") +print("Finished!\nThe analysis used: " + str(end-start) + " seconds") \ No newline at end of file