Skip to content

Commit

Permalink
Merge pull request #49 from AmpliconSuite/unstable_dev
Browse files Browse the repository at this point in the history
Unstable dev
  • Loading branch information
jluebeck authored Dec 13, 2023
2 parents d545710 + e71ced0 commit e688cd1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AmpliconSuite-pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from paalib import check_reference, cnv_prefilter

__version__ = "1.1.1"
__version__ = "1.1.3"

PY3_PATH = "python3" # updated by command-line arg if specified
metadata_dict = {} # stores the run metadata (bioinformatic metadata)
Expand Down
39 changes: 26 additions & 13 deletions GroupedAnalysisAmpSuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def generate_individual_seeds(cmd_dict, aa_py, parent_odir, cnv_bed_dict):

# if it was a seeds file, PAA won't modify, so move it into the right location
if sname in cnv_bed_dict and cnv_bed_dict[sname].endswith("AA_CNV_SEEDS.bed"):
cmd = "cp {} {}/".format(cnv_bed_dict[sname], odir)
call(cmd, shell=True)
if not os.path.dirname(os.path.realpath(cnv_bed_dict[sname])) == os.path.realpath(odir):
cmd = "cp {} {}/".format(cnv_bed_dict[sname], odir)
call(cmd, shell=True)

# store the name of the path of the seeds file
individual_seed_dct[sname] = '{}/{}_AA_CNV_SEEDS.bed'.format(odir, sname)
Expand All @@ -42,17 +43,22 @@ def generate_individual_seeds(cmd_dict, aa_py, parent_odir, cnv_bed_dict):

def group_seeds(individual_seed_dct, odir):
samplist = list(individual_seed_dct.keys())
outname = odir + "_".join(samplist[:2])
if len(samplist) > 2:
outname += "_etc_n" + str(len(samplist))
all_ind_seeds = set(individual_seed_dct.values())
if len(all_ind_seeds) > 1:
outname = odir + "_".join(samplist[:2])
if len(samplist) > 2:
outname += "_etc_n" + str(len(samplist))

outname += "_merged_AA_CNV_SEEDS.bed"
bedlist = " ".join(all_ind_seeds)
print("Merging seeds")
cmd = "sort -k1,1 -k2,2n {} | bedtools merge -i - > {}".format(bedlist, outname)
print(cmd)
call(cmd, shell=True)

outname+="_merged_AA_CNV_SEEDS.bed"
else:
outname = all_ind_seeds.pop()

bedlist = " ".join(individual_seed_dct.values())
print("Merging seeds")
cmd = "sort -k1,1 -k2,2n {} | bedtools merge -i - > {}".format(bedlist, outname)
print(cmd)
call(cmd, shell=True)
gs_dict = {x: outname for x in samplist}
return gs_dict

Expand Down Expand Up @@ -166,7 +172,7 @@ def read_group_data(input_file):
continue

for ind, v in enumerate(fields):
if v.upper() == "NA" or v.upper() == "NONE":
if v.upper() == "NA" or v.upper() == "NONE" or v.upper() == "":
fields[ind] = None

if fields[2].lower() == "tumor":
Expand All @@ -180,7 +186,6 @@ def read_group_data(input_file):
"group input formatting instructions.\n\n")
sys.exit(1)


return tumor_lines, normal_lines


Expand Down Expand Up @@ -292,6 +297,9 @@ def get_argdict(args):
arg_dict = get_argdict(args)
tumor_lines, normal_lines = read_group_data(args.input)
print("Found {} tumor samples and {} normals\n".format(str(len(tumor_lines)), str(len(normal_lines))))
if len(tumor_lines) == 0:
print("No tumor samples were provided. Exiting.")
sys.exit(1)

# Stage 1: iterate over and launch each that needs CN calling. collect CN seeds files
base_argstring = make_base_argstring(arg_dict, stop_at_seeds=True)
Expand All @@ -312,6 +320,11 @@ def get_argdict(args):
if not args.no_AA:
if args.skip_AA_on_normal_bam:
normal_lines = []
else:
grouped_seeds[normal_lines[0][0]] = grouped_seeds[tumor_lines[0][0]]
odir = "{}{}/".format(args.output_directory, normal_lines[0][0])
if not os.path.exists(odir):
os.makedirs(odir)

all_lines = normal_lines + tumor_lines
cmd_dict = create_AA_AC_cmds(all_lines, base_argstring, grouped_seeds, args.output_directory)
Expand Down
4 changes: 2 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name="ampliconsuite" %}
{% set AS_version="1.1.1" %}
{% set AS_version="1.1.2" %}
{% set AA_version="1.3.r6" %}
{% set AC_version="1.0.0" %}

Expand All @@ -11,7 +11,7 @@ source:
# the sha256 sum is generated by doing
# $ wget -O- [URL] | shasum -a 256
- url: https://github.com/AmpliconSuite/AmpliconSuite-pipeline/archive/v{{ AS_version }}.tar.gz
sha256: 0a874698ae3468d6ca02c3a3e1542d945e9940c703cf24c409eeb6e70e3bf3a7
sha256: 4483b38a89dfde309bc82e589c334df010de9315e34115790dd5c664f9f80bde
- url: https://github.com/AmpliconSuite/AmpliconArchitect/archive/v{{ AA_version }}.tar.gz
sha256: cc21a52d9853cd5e0b5b9374773a6ea24191241b9b9cf1d71e2a928ab3d97f01
folder: ampliconarchitectlib
Expand Down

0 comments on commit e688cd1

Please sign in to comment.