Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #196 from joshuabhk/master
Browse files Browse the repository at this point in the history
mirseq_fix
  • Loading branch information
jlac authored Feb 15, 2017
2 parents 7764fa6 + c1a45d2 commit dd6ebdf
Show file tree
Hide file tree
Showing 3 changed files with 199 additions and 3 deletions.
1 change: 1 addition & 0 deletions gui/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ def cmd(self, smcommand):
MkaS=os.popen(PIPELINER_HOME+"/makeasnake.py "+PL+" 2>&1 | tee -a "+self.workpath.get()+"/Reports/makeasnake.log").read()
Out=os.popen("cd "+self.workpath.get()+" && snakemake " + smcommand +" 2>&1").read()
show(Out,"CCBR Pipeliner: "+ pl + " "+smcommand,dryrunFgColor,dryrunBgColor,200,100)
#show(MkaS + "\n" + Out,"CCBR Pipeliner: "+ pl + " "+smcommand,dryrunFgColor,dryrunBgColor,200,100)

def checklist( self ) :
'''placeholder'''
Expand Down
196 changes: 195 additions & 1 deletion gui/mirseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,198 @@ def loadfunc() :

info.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 )
top.focus_force()


def makejson(self, *args):
#print(args[0])
caller=args[0]
#global PD
#global UnitsBak
#global RGbak
D=dict()
try:
F=open(self.workpath.get()+"/samples","r")
f=F.read().split("\n")
F.close()
for line in f:
L=line.split()
a=L.pop(0)
D[a]=L
samples=D
except:
samples={"na":"na"}

D=dict()
try:
F=open(self.workpath.get()+"/pairs","r")
f=F.read().split()
F.close()
for i in range(0,len(f),2):
# a=f[i].split(".")[0]
# b=f[i+1].split(".")[0]
a=f[i]
b=f[i+1]

D[a+"+"+b]=[a,b]

pairs=D
except:
pairs={"na":"na"}

D=dict()
try:
F=open(self.workpath.get()+"/contrasts.tab","r")
# f=F.read().split('\n')
# F.close()
# D["rsamps"]=f[0].split()
# D["rgroups"]=f[1].split()
# D["rcontrasts"]=f[2].split()
# D["rlabels"]=f[3].split()
f=F.readlines()
F.close()
## sampl=[]
## grp=[]
cont=[]
## lbl=[]
for x in f:
if len(x.split()) == 2:
cont.append(x.split()[0])
cont.append(x.split()[1])
D["rcontrasts"]=cont
# contrasts["rcontrasts"]=cont
contrasts=D
except:
contrasts={"rcontrasts":"na"}
## contrasts={"rsamps":"na","rgroups":"na","rcontrasts":"na","rlabels":"na"}
##------
D=dict()
try:
F=open(self.workpath.get()+"/groups.tab","r")
f=F.readlines()
F.close()
sampl=[]
grp=[]
# cont=[]
lbl=[]
for x in f:
# if len(x.split()) == 4 or len(x.split()) == 3:
if len(x.split()) == 3:
sampl.append(x.split()[0])
grp.append(x.split()[1])
lbl.append(x.split()[2])
D["rsamps"]=sampl
D["rgroups"]=grp
D["rlabels"]=lbl
# D["rcontrasts"]="na"
# contrasts=D
groups=D
except:
# contrasts={"rsamps":"na","rgroups":"na","rcontrasts":"na","rlabels":"na"}
groups={"rsamps":"na","rgroups":"na","rlabels":"na"}
##------
D=dict()
FT = filetype#.get()
# p = Popen("ls "+workpath.get()+"/*."+FT, shell=True, stdin=PIPE, stdout=PIPE, stderr=DEVNULL, close_fds=True)
p = Popen("find "+self.workpath.get()+" -maxdepth 1 -type l -printf '%f\n' ", shell=True, stdin=PIPE, stdout=PIPE, stderr=DEVNULL, close_fds=True)
a = p.stdout.read().decode(encoding='UTF-8').split("\n")

RG=dict()
b=a.pop()
# tkinter.messagebox.showerror("",a)
# if freezeunits.get()=="no":
for i in a:

key=re.sub(".realign","",i.split("/")[-1])
key=re.sub(".bai","",key)
key=re.sub(".bam","",key)
key=re.sub(".sam","",key)
key=re.sub(".recal","",key)
key=re.sub(".dedup","",key)
key=re.sub(".sorted","",key)
key=re.sub(".fin","",key)
key=re.sub(".R[12]","",key)
key=re.sub("_R[12]","",key)
key=re.sub(".fastq","",key)
key=re.sub(".gz","",key)
# key=re.sub("[\._](R[12]\.)*"+FT+"$","",i.split("/")[-1])
# key=re.sub(".R[12]."+FT+"$","",i.split("/")[-1])
# key=re.sub("([._]R[12][._])*([fin|sorted|dedup|recal|realign])*\.{0}$".format(FT),"",i.split("/")[-1])
D[key]=key
RG[key]={'rgsm':key,'rglb':'na','rgpu':'na','rgpl':'ILLUMINA','rgcn':'na'}
units=D
UnitsBak=D

try:
F=open(self.workpath.get()+"/rg.tab","r")
f=F.read().splitlines()
F.close()
for theLine in f:
if not re.match("^ID",theLine):
(rgid,rgsm,rglb,rgpl,rgpu,rgcn)=theLine.split("\t")
RG[rgid]={'rgsm':rgsm,'rglb':rglb,'rgpu':rgpu,'rgpl':rgpl,'rgcn':rgcn}
except:
pass

RGbak=RG
# else:
# units=UnitsBak
# RG=RGbak
#
PD=dict()

smparams=[]

for i in range(len(self.parameters)):

if cp[i].var.get()=="1":
smparams.append(parameters[i])

AD=eval( open( join(PIPELINER_HOME,
self.annotation.get()+".json"
), "r"
).read()
)

SD=AD['references']['rnaseq']['STARDIR']
# tkinter.messagebox.showinfo("initLock","SD={0}".format(SD))
gi = self.global_info
PD={
'project': {
'pfamily': gi.pfamily.get(),
'units': units,
'samples': samples,
'pairs': pairs,
'id': gi.eprojectid.get(),
'pi': gi.epi.get(),
'organism': gi.eorganism.get(),
'analyst': gi.eanalyst.get(),
'poc': gi.epoc.get(),
'pipeline': self.Pipeline.get(),
'version':"1.0",
'annotation': gi.annotation.get(),
'datapath': self.datapath.get(),
'targetspath': self.targetspath.get(),
'filetype': filetype ,
'binset': "standard-bin",
'username': gi.euser.get(),
'flowcellid': gi.eflowcell.get(),
'platform': gi.eplatform.get(),
'custom': customRules,
'efiletype': efiletype,
'workpath': self.workpath.get(),
'batchsize': batchsize,
"smparams": smparams,
"rgid": RG,
"cluster": "cluster_medium.json",
"description": gi.description.get('1.0',END),
"technique" : gi.technique.get(),
"TRIM": "yes",
"groups": groups,
"contrasts": contrasts,
}
}

J=json.dumps(PD, sort_keys = True, indent = 4, ensure_ascii=True)
gi.jsonconf.delete("1.0", END)
gi.jsonconf.insert(INSERT, J)
self.saveproject(gi.jsonconf.get("1.0",END))

5 changes: 3 additions & 2 deletions makeasnake.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env python
import sys,os,re,subprocess
import json
from sys import stderr
#from subprocess import call,Popen, PIPE, STDOUT

#pathprj= os.path.dirname(sys.argv[1])
pathprj= sys.argv[1]
print(pathprj)
print(pathprj+"/project.json")
print(pathprj, file=stderr)
print(pathprj+"/project.json", file=stderr)

whereiam=os.popen("pwd").read().strip()

Expand Down

0 comments on commit dd6ebdf

Please sign in to comment.