Commit 21966517 authored by Maria Bernard's avatar Maria Bernard
Browse files

No commit message

No commit message
parent b9143e84
......@@ -23,15 +23,16 @@ from collections import Counter
import numpy as np
import re
def wrap_cstacks(exec_path, mismatch, batch_id, inputs_tags_list, output_tags, output_alleles, output_snps, stderr_path):
def wrap_cstacks(exec_path, mismatch, batch_id, out_dir, inputs_tags_list, output_tags, output_alleles, output_snps, stderr_path):
from subprocess import Popen, PIPE
cmd = [exec_path, "-b", batch_id, "-n", mismatch, "-o", out_dir]
inputs = ""
with open(inputs_tags_list, 'r') as input_tags :
for i in input_tags:
inputs += " -s " + os.path.abspath(i.strip()).replace(".tags"," ").split(" ")[0]
out_dir=os.path.dirname(output_tags)
cmd = [exec_path.strip(), " -b ", str(batch_id) , " -n ", str(mismatch), inputs, " -o ",out_dir ]
cmd.append("-s")
cmd.append(os.path.abspath(i.strip()).replace(".tags"," ").split(" ")[0])
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
# write down the stderr
......@@ -39,10 +40,6 @@ def wrap_cstacks(exec_path, mismatch, batch_id, inputs_tags_list, output_tags, o
stdeh.write(stderr)
stdeh.close()
# cmd = exec_path+" -b "+str(batch_id)+" -n "+str(mismatch)+inputs+" -o "+out_dir+" 2> "+stderr_path
# os.system(cmd)
print cmd
class Cstacks (Analysis):
def define_parameters(self, alleles_files, snps_files, tags_files, samples_id, population_list, batch_id=1, mismatch=1):
......@@ -99,7 +96,7 @@ class Cstacks (Analysis):
cstacks = PythonFunction(wrap_cstacks, cmd_format='{EXE} {ARG} {IN} {OUT}')
cstacks(inputs = [tmp_list_file], outputs = [self.catalog_tags, self.catalog_alleles, self.catalog_snps, self.stderr], \
arguments = [self.get_exec_path("cstacks"), self.mismatch, self.batch_id], \
arguments = [self.get_exec_path("cstacks"), self.mismatch, self.batch_id,self.output_directory], \
includes = [self.tags_files, self.alleles_files, self.snps_files])
def post_process(self):
......
......@@ -43,7 +43,7 @@ class Ustacks (Analysis):
@param bound_high (--bound_high) : upper bound for epsilon, the error rate, between 0 and 1.0 (default 1).
@param bc_err_freq (--bc_err_freq) : specify the barcode error frequency, between 0 and 1.0.
"""
self.add_input_file_list( "samples_id", "individuals id list", default=samples_id, required=True)
self.add_parameter_list( "samples_id", "individuals id list", default=samples_id, required=True)
self.add_input_file_list( "read1_files", "paths to reads 1", default=read1_files, required=True)
if len(self.read1_files) != len(self.samples_id):
raise Exception("[ERROR] : the number of files and the number of id are not equal. Please check your inputs")
......
......@@ -67,6 +67,7 @@ class RADseq (NG6Workflow):
self.add_parameter("max_locus", "max stacks per cluster", type=int)
# cstacks
self.add_parameter("batch_id", " batch_id of this radseq analysis",default = 1, type=int)
self.add_parameter("catalog_mismatches", "How many mismatches allowed between sample to generate the cluster catalog",default = 1, type=int)
# ng6
......@@ -154,6 +155,7 @@ class RADseq (NG6Workflow):
# print ustacks_opt
ustacks = self.add_component("Ustacks", [],ustacks_opt)
#cstacks = self.add_component("Cstacks", [ustacks.alleles, ustacks.snps, ustacks.tags, self.args["catalog_mismatches"]])
# CSTACKS
cstacks = self.add_component("Cstacks", [ustacks.alleles, ustacks.snps, ustacks.tags, self.batch_id, self.catalog_mismatches])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment