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

Work-around for lumpy segfaults from lumpyexpress #277

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 3 additions & 6 deletions scripts/lumpyexpress
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ do
x)
EXCLUDE_BED="$OPTARG"
EXCLUDE_BED_FMT="-x $EXCLUDE_BED"
;;
;;
T)
TEMP_DIR="$OPTARG"
;;
Expand Down Expand Up @@ -438,7 +438,7 @@ then
mv ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).discordants.bam ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).discordants.bam
mv ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).splitters.bam ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).splitters.bam
fi

# update the splitters and discordant BAM lists
SPL_BAM_LIST+=(${TEMP_DIR}/$OUTBASE.sample$(($i+1)).splitters.bam)
DISC_BAM_LIST+=(${TEMP_DIR}/$OUTBASE.sample$(($i+1)).discordants.bam)
Expand Down Expand Up @@ -500,10 +500,7 @@ else
STDEV=`cat ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).insert.stats | tr '\t' '\n' | grep "^stdev" | sed 's/stdev\://g'`
RG_STRING=`echo "${LIB_RG_LIST[$j]}" | sed 's/,/,read_group:/g' | sed 's/^/read_group:/g'`

if [[ "$MEAN" != "NA" ]] && [[ "$STDEV" != "NA" ]]
then
LUMPY_DISC_STRING="$LUMPY_DISC_STRING -pe bam_file:${DISC_BAM},histo_file:${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).x4.histo,mean:${MEAN},stdev:${STDEV},read_length:${LIB_READ_LENGTH_LIST[$j]},min_non_overlap:${LIB_READ_LENGTH_LIST[$j]},discordant_z:5,back_distance:10,weight:1,id:${DISC_SAMPLE},min_mapping_threshold:20,${RG_STRING}"
fi
LUMPY_DISC_STRING="$LUMPY_DISC_STRING -pe bam_file:${DISC_BAM},histo_file:${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).x4.histo,mean:${MEAN},stdev:${STDEV},read_length:${LIB_READ_LENGTH_LIST[$j]},min_non_overlap:${LIB_READ_LENGTH_LIST[$j]},discordant_z:5,back_distance:10,weight:1,id:${DISC_SAMPLE},min_mapping_threshold:20,${RG_STRING}"
done
done
fi
Expand Down
35 changes: 16 additions & 19 deletions scripts/pairend_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,22 @@ def mean_std(L):
min_elements = 1000
if len(L) < min_elements:
sys.stderr.write("Warning: only %s elements in distribution (min: %s)\n" % (len(L), min_elements))
mean = "NA"
stdev = "NA"

else:
# Remove outliers
med, umad = unscaled_upper_mad(L)
upper_cutoff = med + options.mads * umad
L = [v for v in L if v < upper_cutoff]
new_len = len(L)
removed = c - new_len
sys.stderr.write("Removed %d outliers with isize >= %d\n" %
(removed, upper_cutoff))
c = new_len

mean, stdev = mean_std(L)

# Remove outliers
med, umad = unscaled_upper_mad(L)
upper_cutoff = med + options.mads * umad
L = [v for v in L if v < upper_cutoff]
new_len = len(L)
removed = c - new_len
sys.stderr.write("Removed %s outliers with isize >= %s\n" %
(removed, upper_cutoff))
c = new_len

mean, stdev = mean_std(L)

f = open(options.output_file, 'w')

if not np.isnan(mean) and not np.isnan(stdev):
start = options.read_length
end = int(mean + options.X*stdev)

Expand All @@ -140,13 +140,10 @@ def mean_std(L):
H[j] = H[ int(x - start) ] + 1
s += 1

f = open(options.output_file, 'w')

for i in range(end - start):
o = str(i) + "\t" + str(float(H[i])/float(s)) + "\n"
f.write(o)


f.close()
f.close()

print(('mean:' + str(mean) + '\tstdev:' + str(stdev)))