Skip to content
Snippets Groups Projects
Commit 276dac3b authored by Venkat Malladi's avatar Venkat Malladi
Browse files

Fix rename.

parent 55a605d1
No related merge requests found
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
import argparse import argparse
import logging import logging
import os import os
import subprocess
import shutil
import shlex
import pandas as pd import pandas as pd
import numpy as np import numpy as np
import utils import utils
...@@ -140,21 +143,29 @@ def self_psuedoreplication(tag_file, prefix, paired): ...@@ -140,21 +143,29 @@ def self_psuedoreplication(tag_file, prefix, paired):
splits_prefix = 'temp_split' splits_prefix = 'temp_split'
out, err = utils.run_pipe([ psuedo_command = 'bash -c "zcat {} | shuf --random-source=<(openssl enc -aes-256-ctr -pass pass:$(zcat -f {} | wc -c) -nosalt </dev/zero 2>/dev/null) | '
'gzip -dc %s' % (tag_file), psuedo_command += 'split -d -l {} - {}."'
'shuf --random-source=<(openssl enc -aes-256-ctr -pass pass:$(zcat -f %s | wc -c) -nosalt </dev/zero 2>/dev/null)' % (tag_file), psuedo_command = psuedo_command.format(
'split -d -l %d - %s' % (lines_per_rep, splits_prefix)]) tag_file,
tag_file,
int(lines_per_rep),
splits_prefix)
logger.info("Running psuedo with %s", psuedo_command)
subprocess.check_call(shlex.split(psuedo_command))
logger.info("Running bwa with %s", bwa_command)
subprocess.check_call(shlex.split(bwa_command), stdout=sai_file)
# Convert read pairs to reads into standard tagAlign file # Convert read pairs to reads into standard tagAlign file
for i, index in enumerate([0, 1]): for i, index in enumerate([0, 1]):
string_index = '0' + str(index) string_index = '.0' + str(index)
steps = ['cat %s' % (splits_prefix + string_index)] steps = ['cat %s' % (splits_prefix + string_index)]
if paired: if paired:
steps.extend([r"""awk 'BEGIN{OFS="\t"}{printf "%s\t%s\t%s\tN\t1000\t%s\n%s\t%s\t%s\tN\t1000\t%s\n",$1,$2,$3,$9,$4,$5,$6,$10}'"""]) steps.extend([r"""awk 'BEGIN{OFS="\t"}{printf "%s\t%s\t%s\tN\t1000\t%s\n%s\t%s\t%s\tN\t1000\t%s\n",$1,$2,$3,$9,$4,$5,$6,$10}'"""])
steps.extend(['gzip -cn']) steps.extend(['gzip -cn'])
out, err = utils.run_pipe(steps, outfile=pseudoreplicate_dict[i]) out, err = utils.run_pipe(steps, outfile=pseudoreplicate_dict[i])
os.remove(splits_prefix + string_index)
return pseudoreplicate_dict return pseudoreplicate_dict
......
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