Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to turn off the region filter. #31

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version 1.9.0-dev
-----------------
+ Add a no filter region filter.
+ Fix a bug where tar would not open certain filenames.

version 1.8.1
Expand Down
3 changes: 2 additions & 1 deletion merge_and_filter.r
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ if(empty.region.filter == "leader"){
} else if(empty.region.filter == "FR2"){
result = result[result$CDR2.IMGT.seq != "" & result$FR3.IMGT.seq != "", ]
}
# If empty region filter is None, nothing happens.

print(paste("After removal sequences that are missing a gene region:", nrow(result)))
filtering.steps = rbind(filtering.steps, c("After removal sequences that are missing a gene region", nrow(result)))
Expand Down Expand Up @@ -219,7 +220,7 @@ if(filter.unique != "no"){
clmns = names(result)
if(filter.unique == "remove_vjaa"){
result$unique.def = paste(result$VGene, result$JGene, result$CDR3.IMGT.AA)
} else if(empty.region.filter == "leader"){
} else if(empty.region.filter == "leader" || empty.region.filter == "None"){
result$unique.def = paste(result$FR1.IMGT.seq, result$CDR1.IMGT.seq, result$FR2.IMGT.seq, result$CDR2.IMGT.seq, result$FR3.IMGT.seq, result$CDR3.IMGT.seq)
} else if(empty.region.filter == "FR1"){
result$unique.def = paste(result$CDR1.IMGT.seq, result$FR2.IMGT.seq, result$CDR2.IMGT.seq, result$FR3.IMGT.seq, result$CDR3.IMGT.seq)
Expand Down
2 changes: 1 addition & 1 deletion nt_overview.r
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hotspot.analysis.sum = read.table(hotspot.analysis.sum.file, header=F, sep=",",

NToverview = merged

if(empty.region.filter == "leader"){
if(empty.region.filter == "leader" || empty.region.filter == "None"){
NToverview$seq = paste(NToverview$FR1.IMGT.seq, NToverview$CDR1.IMGT.seq, NToverview$FR2.IMGT.seq, NToverview$CDR2.IMGT.seq, NToverview$FR3.IMGT.seq)
} else if(empty.region.filter == "FR1"){
NToverview$seq = paste(NToverview$CDR1.IMGT.seq, NToverview$FR2.IMGT.seq, NToverview$CDR2.IMGT.seq, NToverview$FR3.IMGT.seq)
Expand Down
2 changes: 1 addition & 1 deletion sequence_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def sequence_overview(before_unique: str,
sequence_columns = [
"FR1.IMGT.seq", "CDR1.IMGT.seq", "FR2.IMGT.seq", "CDR2.IMGT.seq",
"FR3.IMGT.seq", "CDR3.IMGT.seq"]
if empty_region_filter == "leader":
if empty_region_filter == "leader" or empty_region_filter == "None":
sequence_columns = sequence_columns
elif empty_region_filter == "FR1":
sequence_columns = sequence_columns[1:]
Expand Down
25 changes: 17 additions & 8 deletions shm_csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
import logging
import sys
import os
import traceback
import typing
from typing import Optional

from collections import defaultdict

REGION_FILTERS = ("leader", "FR1", "CDR1", "FR2", "CDR2")
REGION_FILTERS = ("leader", "FR1", "CDR1", "FR2", "CDR2", "None")


def int_or_zero(value: typing.Any):
try:
return int(value)
except ValueError:
return 0

class Mutation(typing.NamedTuple):
"""Represent a mutation type as a tuple"""
frm: str # 'from' is a reserved python keyword.
Expand Down Expand Up @@ -177,15 +184,15 @@ def main():
mutationList += mutationdic[ID + "_FR1"] + mutationdic[ID + "_CDR1"] + mutationdic[ID + "_FR2"] + mutationdic[ID + "_CDR2"] + mutationdic[ID + "_FR3"]
mutationListByID[ID] = mutationdic[ID + "_FR1"] + mutationdic[ID + "_CDR1"] + mutationdic[ID + "_FR2"] + mutationdic[ID + "_CDR2"] + mutationdic[ID + "_FR3"]

fr1Length = int(linesplt[fr1LengthIndex])
fr2Length = int(linesplt[fr2LengthIndex])
fr3Length = int(linesplt[fr3LengthIndex])
cdr1Length = int(linesplt[cdr1LengthIndex])
cdr2Length = int(linesplt[cdr2LengthIndex])
fr1Length = int_or_zero(linesplt[fr1LengthIndex])
fr2Length = int_or_zero(linesplt[fr2LengthIndex])
fr3Length = int_or_zero(linesplt[fr3LengthIndex])
cdr1Length = int_or_zero(linesplt[cdr1LengthIndex])
cdr2Length = int_or_zero(linesplt[cdr2LengthIndex])
LengthDic[ID] = (fr1Length, cdr1Length, fr2Length, cdr2Length, fr3Length)

cdr1AALengthDic[ID] = int(linesplt[cdr1AALengthIndex])
cdr2AALengthDic[ID] = int(linesplt[cdr2AALengthIndex])
cdr1AALengthDic[ID] = int_or_zero(linesplt[cdr1AALengthIndex])
cdr2AALengthDic[ID] = int_or_zero(linesplt[cdr2AALengthIndex])

IDlist += [ID]
print("len(mutationdic) =", len(mutationdic))
Expand Down Expand Up @@ -222,6 +229,8 @@ def main():
# We determine the position to start summing below.
# This returns 0 for leader, 1 for FR1 etc.
length_start_pos = REGION_FILTERS.index(empty_region_filter)
if empty_region_filter == "None":
length_start_pos = 0

o.write("Sequence.ID\tnumber_of_mutations\tnumber_of_tandems\tregion_length\texpected_tandems\tlongest_tandem\ttandems\n")
for ID in IDlist:
Expand Down
1 change: 1 addition & 0 deletions shm_csr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<option value="FR1" selected="true">FR1: include CDR1,FR2,CDR2,FR3 in filters</option>
<option value="CDR1">CDR1: include FR2,CDR2,FR3 in filters</option>
<option value="FR2">FR2: include CDR2,FR3 in filters</option>
<option value="None">No filter: sequences with mission regions are not filtered.</option>
</param>
<param name="functionality" type="select" label="Functionality filter" help="" >
<option value="productive" selected="true">Productive (Productive and Productive see comment)</option>
Expand Down
2 changes: 1 addition & 1 deletion wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ NEW_IMGT_PREFIX=${NEW_IMGT_PREFIX// /_}
#exec 5> debug_output.txt
#BASH_XTRACEFD="5"
## Busybox date does not support '+%s.%N'. So use a custom program. Can be
## Compiled with cc -Os show_time_as_float.c -o show_time_as_float
## Compiled with cc -static -Os show_time_as_float.c -o show_time_as_float
#PS4='$(${dir}/show_time_as_float) $LINENO: '
#set -x

Expand Down
Loading