Skip to content

Commit

Permalink
Merge pull request #36 from LUMC/release_1.10.0
Browse files Browse the repository at this point in the history
Release 1.10.0
  • Loading branch information
rhpvorderman authored Jan 10, 2024
2 parents 91fd26f + fa7a535 commit bb8e490
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 56 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ jobs:
# Make sure everything works correctly by default.
# SHM_CSR_FAST: yes runs by default on the local test.
SHM_CSR_FAST: "no"
- name: Print stdout
run: bash -c 'cat /tmp/tmp*/stdout'
if: failure()
- name: Print stderr
run: bash -c 'cat /tmp/tmp*/stderr'
if: failure()
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
version 1.10.0-dev
------------------
+ Fix crashing baseline when only unproductive sequences are present.
+ Replace "fast" option with options to toggle baseline and Change-O indidually.

version 1.9.1
-----------------
+ Fix error in launch command.
Expand Down
17 changes: 10 additions & 7 deletions baseline/wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

dir="$(cd "$(dirname "$0")" && pwd)"

testID=$1
Expand Down Expand Up @@ -79,14 +80,16 @@ Rscript --verbose $dir/Baseline_Main.r $testID $species $substitutionModel $muta

echo "$workdir/${outID}.txt"

rows=`tail -n +2 $workdir/${outID}.txt | grep -v "All sequences combined" | grep -n 'Group' | grep -Eoh '^[0-9]+' | tr '\n' ' '`
rows=($rows)
#unset rows[${#rows[@]}-1]

cd $dir
Rscript --verbose $dir/comparePDFs.r $workdir/${outID}.RData $output ${rows[@]} 2>&1
cp $workdir/result.txt ${output_table}
if [[ -f "$workdir/${outID}.txt" ]]
then
rows=`tail -n +2 $workdir/${outID}.txt | grep -v "All sequences combined" | grep -n 'Group' | grep -Eoh '^[0-9]+' | tr '\n' ' '`
rows=($rows)
#unset rows[${#rows[@]}-1]

cd $dir
Rscript --verbose $dir/comparePDFs.r $workdir/${outID}.RData $output ${rows[@]} 2>&1
cp $workdir/result.txt ${output_table}
fi



40 changes: 19 additions & 21 deletions shm_csr.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="shm_csr" name="SHM &amp; CSR pipeline" version="1.9.1" profile="16.04">
<tool id="shm_csr" name="SHM &amp; CSR pipeline" version="1.10.0-dev" profile="16.04">
<description></description>
<requirements>
<requirement type="package" version="3.7.1">python</requirement>
Expand Down Expand Up @@ -35,7 +35,7 @@
$filter_unique.filter_unique_clone_count
$class_filter_cond.class_filter
$empty_region_filter
$fast
$changeo $baseline
#else:
$__tool_directory__/wrapper.sh "$in_file"
custom
Expand All @@ -48,7 +48,7 @@
2
$class_filter_cond.class_filter
$empty_region_filter
$fast
$changeo $baseline
#end if
]]>
</command>
Expand Down Expand Up @@ -108,59 +108,57 @@
</param>
</conditional>
<conditional name="naive_output_cond">
<param name="naive_output" type="select" label="Output new IMGT archives per class into your history?">
<option value="yes">Yes</option>
<option value="no" selected="true">No</option>
</param>
<when value="yes"></when>
<when value="no"></when>
</conditional>
<param name="fast" type="select" label="Fast" help="Skips Change-O/Baseline" >
<option value="yes">Yes</option>
<option value="no" selected="true">No</option>
</param>
<param name="naive_output" type="boolean" label="Output new IMGT archives per class into your history?"
checked="no" truevalue="yes" falsevalue="no"/>
</conditional>
<param name="changeo" type="boolean" label="Run Change-O"
checked="yes" truevalue="yes" falsevalue="no"/>
<param name="baseline" type="boolean" label="Run Baseline"
checked="yes" truevalue="yes" falsevalue="no"
help="Baseline is automatically skipped when functionality filter is set to unproductive only."
/>
</inputs>
<outputs>
<data format="html" name="out_file" label = "SHM &amp; CSR on ${in_file.name}"/>
<data format="imgt_archive" name="naive_output_ca" label = "Filtered IMGT IGA: ${in_file.name}" >
<filter>naive_output_cond['naive_output'] == "yes"</filter>
<filter>naive_output_cond['naive_output'] is True</filter>
<filter>class_filter_cond['class_filter'] != "101_101"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGG"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGM"</filter>
</data>
<data format="imgt_archive" name="naive_output_cg" label = "Filtered IMGT IGG: ${in_file.name}" >
<filter>naive_output_cond['naive_output'] == "yes"</filter>
<filter>naive_output_cond['naive_output'] is True</filter>
<filter>class_filter_cond['class_filter'] != "101_101"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGA"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGM"</filter>
</data>
<data format="imgt_archive" name="naive_output_cm" label = "Filtered IMGT IGM: ${in_file.name}" >
<filter>naive_output_cond['naive_output'] == "yes"</filter>
<filter>naive_output_cond['naive_output'] is True</filter>
<filter>class_filter_cond['class_filter'] != "101_101"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGA"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGG"</filter>
</data>
<data format="imgt_archive" name="naive_output_ce" label = "Filtered IMGT IGE: ${in_file.name}" >
<filter>naive_output_cond['naive_output'] == "yes"</filter>
<filter>naive_output_cond['naive_output'] is True</filter>
<filter>class_filter_cond['class_filter'] != "101_101"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGA"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGG"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGM"</filter>
</data>
<data format="imgt_archive" name="naive_output_igm_naive" label = "Filtered naive IGM sequences (mutations below 2%): ${in_file.name}">
<filter>naive_output_cond['naive_output'] == "yes"</filter>
<filter>naive_output_cond['naive_output'] is True</filter>
<filter>class_filter_cond['class_filter'] != "101_101"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGA"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGG"</filter>
</data>
<data format="imgt_archive" name="naive_output_igm_naive_memory" label = "Filtered naive memory IGM sequences (mutations over 2%): ${in_file.name}">
<filter>naive_output_cond['naive_output'] == "yes"</filter>
<filter>naive_output_cond['naive_output'] is True</filter>
<filter>class_filter_cond['class_filter'] != "101_101"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGA"</filter>
<filter>class_filter_cond['class_filter'] != "101_101_IGG"</filter>
</data>
<data format="imgt_archive" name="naive_output_all" label = "Filtered IMGT all: ${in_file.name}" >
<filter>naive_output_cond['naive_output'] == "yes"</filter>
<filter>naive_output_cond['naive_output'] is True</filter>
<filter>class_filter_cond['class_filter'] == "101_101"</filter>
</data>
</outputs>
Expand Down
71 changes: 46 additions & 25 deletions tests/test_shm_csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,31 @@ def ignore_files(src, files):
return files
return ()

@pytest.fixture(scope="module")
def shm_csr_result():

def run_shm_csr(
input=str(CONTROL_NWK377_PB_IGHC_MID1_40nt_2),
infile_name = "input_data",
functionality = "productive",
unique = "Sequence.ID",
naive_output = "no",
naive_output_ca = "None",
naive_output_cg = "None",
naive_output_cm = "None",
naive_output_ce = "None",
naive_output_all = "None",
naive_output_igm_naive = "None",
naive_output_igm_naive_memory = "None",
filter_unique = "remove",
filter_unique_count = '2',
class_filter = '70_70',
empty_region_filter = 'FR1',
# Skip baseline and changeo by default. These tools cannot be modified
# anyway and take most of the test time to execute. The environment
# variable can be set to "no" on the CI so the code path is tested
# at the time a PR is ready.
run_changeo = "yes" if os.environ.get("SHM_CSR_FAST") == "no" else "no",
run_baseline = "yes" if os.environ.get("SHM_CSR_FAST") == "no" else "no",
):
temp_dir = Path(tempfile.mkdtemp())
tool_dir = temp_dir / "shm_csr"
shutil.copytree(
Expand All @@ -62,29 +85,8 @@ def shm_csr_result():
output_dir = temp_dir / "outputs"
output_dir.mkdir(parents=True)
wrapper = str(tool_dir / "wrapper.sh")
input = str(CONTROL_NWK377_PB_IGHC_MID1_40nt_2)
out_files_path = output_dir / "results"
out_file = out_files_path / "result.html"
infile_name = "input_data"
functionality = "productive"
unique = "Sequence.ID"
naive_output = "no"
naive_output_ca = "None"
naive_output_cg = "None"
naive_output_cm = "None"
naive_output_ce = "None"
naive_output_all = "None"
naive_output_igm_naive = "None"
naive_output_igm_naive_memory = "None"
filter_unique = "remove"
filter_unique_count = '2'
class_filter = '70_70'
empty_region_filter = 'FR1'
# Skip baseline and changeo by default. These tools cannot be modified
# anyway and take most of the test time to execute. The environment
# variable can be set to "no" on the CI so the code path is tested
# at the time a PR is ready.
fast = os.environ.get("SHM_CSR_FAST", "yes")
cmd = [
"bash",
wrapper,
Expand All @@ -108,7 +110,8 @@ def shm_csr_result():
filter_unique_count,
class_filter,
empty_region_filter,
fast
run_changeo,
run_baseline
]
docker_cmd = ["docker", "run", "-v", f"{temp_dir}:{temp_dir}",
"--rm", # Remove container after running
Expand All @@ -128,7 +131,12 @@ def shm_csr_result():
with open(temp_dir / "stdout", "wt") as stdout_file:
subprocess.run(docker_cmd, cwd=working_dir, stdout=stdout_file,
stderr=stderr_file, check=True)
yield Path(out_files_path)
return Path(out_files_path)


@pytest.fixture(scope="module")
def shm_csr_result():
yield run_shm_csr()


def test_check_output(shm_csr_result):
Expand Down Expand Up @@ -157,3 +165,16 @@ def test_nt_overview(shm_csr_result):
) as validate_h:
for line in result_h:
assert line == validate_h.readline()


def test_baseline_succeeds():
run_shm_csr(
functionality="unproductive",
empty_region_filter="None",
filter_unique="no",
unique="VGene,DGene,JGene,CDR3.IMGT.seq",
class_filter="101_101_IGA",
naive_output="yes",
run_baseline="yes",
run_changeo="yes",
)
7 changes: 4 additions & 3 deletions wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ filter_unique=${17}
filter_unique_count=${18}
class_filter=${19}
empty_region_filter=${20}
fast=${21}
run_changeo=${21}
run_baseline=${22}
BASENAME=$(basename "$title")
# Cut off .txz or .tgz suffix and also replace spaces with underscores.
NEW_IMGT_PREFIX="new_IMGT_${BASENAME%.*}"
Expand Down Expand Up @@ -410,7 +411,7 @@ count_imgt_lines () {
rm 1_Summary.txt
}

if [[ "$fast" == "no" ]] ; then
if [[ "$run_baseline" == "yes" ]] ; then



Expand Down Expand Up @@ -524,7 +525,7 @@ cat $dir/shm_csr.htm >> $output

echo "</div>" >> $output #CSR tab end

if [[ "$fast" == "no" ]] ; then
if [[ "$run_changeo" == "yes" ]] ; then

echo "---------------- change-o MakeDB ----------------"

Expand Down

0 comments on commit bb8e490

Please sign in to comment.