diff cpo_galaxy_tree.py @ 7:4d2777aa99db draft

planemo upload
author jjjjia
date Thu, 23 Aug 2018 18:35:54 -0400
parents cabceaa239e4
children 93c25036d3b9
line wrap: on
line diff
--- a/cpo_galaxy_tree.py	Thu Aug 23 12:21:15 2018 -0400
+++ b/cpo_galaxy_tree.py	Thu Aug 23 18:35:54 2018 -0400
@@ -4,17 +4,24 @@
 #$ -V             # Pass environment variables to the job
 #$ -N CPO_pipeline    # Replace with a more specific job name
 #$ -wd /home/jjjjia/testCases           # Use the current working dir
-#$ -pe smp 8      # Parallel Environment (how many cores)
+#$ -pe smp 1      # Parallel Environment (how many cores)
 #$ -l h_vmem=11G  # Memory (RAM) allocation *per core*
 #$ -e ./logs/$JOB_ID.err
 #$ -o ./logs/$JOB_ID.log
 #$ -m ea
 #$ -M bja20@sfu.ca
 
-#~/scripts/pipeline.py -i BC11-Kpn005_S2 -f /data/jjjjia/R1/BC11-Kpn005_S2_L001_R1_001.fastq.gz -r /data/jjjjia/R2/BC11-Kpn005_S2_L001_R2_001.fastq.gz -o pipelineResultsQsub -e "Klebsiella pneumoniae" 
+#   >python cpo_galaxy_tree.py -t /path/to/tree.ph -d /path/to/distance/matrix -m /path/to/metadata
+
+#	<requirements>
+#		<requirement type="package" version="0.23.4">pandas</requirement>
+#		<requirement type="package" version="3.6">python</requirement>
+#       <requirement type="package" version="3.1.1">ete3</requirement>
+#		<requirement type="package" version="5.9.3">pyqt</requirement>
+#  </requirements>
 
 import subprocess
-import pandas
+import pandas #conda pandas
 import optparse
 import os
 import datetime
@@ -24,8 +31,8 @@
 import gzip
 import collections
 import json
-import numpy
-import ete3 as e
+import numpy #conda numpy
+import ete3 as e #conda ete3 3.1.1**** >requires pyqt5
 
 
 #parses some parameters
@@ -69,9 +76,9 @@
 #endregion
 
 #region useful functions
-def read(path):
+def read(path): #read in a text file to a list
     return [line.rstrip('\n') for line in open(path)]
-def execute(command):
+def execute(command): #subprocess.popen call bash command
     process = subprocess.Popen(command, shell=False, cwd=curDir, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
     # Poll process for new output until finished
@@ -89,13 +96,13 @@
         return output
     else:
         raise subprocess.CalledProcessError(exitCode, command)
-def httpGetFile(url, filepath=""):
+def httpGetFile(url, filepath=""): #download a file from the web
     if (filepath == ""):
         return urllib.request.urlretrieve(url)
     else:
         urllib.request.urlretrieve(url, filepath)
         return True
-def gunzip(inputpath="", outputpath=""):
+def gunzip(inputpath="", outputpath=""): #gunzip
     if (outputpath == ""):
         with gzip.open(inputpath, 'rb') as f:
             gzContent = f.read()
@@ -106,7 +113,7 @@
         with open(outputpath, 'wb') as out:
             out.write(gzContent)
         return True
-def addFace(name):
+def addFace(name): #function to add a facet to a tree
     #if its the reference branch, populate the faces with column headers
     face = e.faces.TextFace(name,fsize=10,tight_text=True)
     face.border.margin = 5