Skip to content

corrected the wrong stats output of number of footprints after filter #75

Merged
merged 4 commits into from
Jan 18, 2019

Conversation

JannikHamp
Copy link
Collaborator

wrong file was chosen. filtered_flagged.bed is the corresct one instead of filtered.bed

renewiegandt and others added 3 commits January 13, 2019 21:45
wrong file was chosen. filtered_flagged.bed is the corresct one instead of filtered.bed
@renewiegandt
Copy link
Collaborator

Please set the target branch to dev. We do not merge directly into the master branch.

@renewiegandt
Copy link
Collaborator

I tested the changes.
It is close but not correct. In the test output file, I generated are 807 footprints.
In the stats it tells me it has 806 footprints. Could it be that you subtract 1 of the total number of footprints?

Copy link
Collaborator

@renewiegandt renewiegandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment.
If you write a header to the temp-files depending on parameters or other factors, please check if the header exists before subtracting 1.

@@ -279,7 +279,7 @@ then
# add some final values to the log file
fp_initial=`cat $data | wc -l`
fp_initial=`expr $fp_initial - 1`
fp_final=`cat "$workdir"/filtered.bed | wc -l`
fp_final=`cat "$workdir"/filtered_flagged.bed | wc -l`
fp_final=`expr $fp_final - 1`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the -1 from line 283. Since you are not writing a header to this temp-file you do not need to subtract 1.

@renewiegandt
Copy link
Collaborator

I think what you are doing is not quite correct.
You check if the input file has got a header. If it does you write the header to your output file. Then you count the lines from your temp-file and subtract 1. But your temp-fille does not contain a header only your in- and output file.
You can do following:
Instead of:

# check if header existed. If so, final output also has a header.
first_line=`sed -n 1p $data | sed "s/$/\tcontains_maxpos\tsequence/"`
if [[ ${first_line:0:1} == "#" ]]
then
	echo "$first_line" > $output
	# add some final values to the log file
	fp_initial=`cat $data | wc -l`
	fp_initial=`expr $fp_initial - 1`
	fp_final=`cat "$workdir"/filtered_flagged.bed | wc -l`
	fp_final=`expr $fp_final - 1`
	echo $fp_initial | sed 's/^/initial number of footprints: /g' >> "$workdir"/compareBed.stats
	echo $fp_final | sed 's/^/number of footprints after subtract: /g' >> "$workdir"/compareBed.stats
else
	# output will be overwritten if it exists
	rm -f $output
	# add some final values to the log file
	cat $data | wc -l | sed 's/^/initial number of footprints: /g' >> "$workdir"/compareBed.stats
	cat "$workdir"/filtered_flagged.bed | wc -l | sed 's/^/number of footprints after subtract: /g' >> "$workdir"/compareBed.stats
fi

do this:

# check if header existed. If so, final output also has a header.
first_line=`sed -n 1p $data | sed "s/$/\tcontains_maxpos\tsequence/"`
if [[ ${first_line:0:1} == "#" ]]
then
	echo "$first_line" > $output
fi
# output will be overwritten if it exists
rm -f $output
# add some final values to the log file
cat $data | wc -l | sed 's/^/initial number of footprints: /g' >> "$workdir"/compareBed.stats
cat "$workdir"/filtered_flagged.bed | wc -l | sed 's/^/number of footprints after subtract: /g' >> "$workdir"/compareBed.stats

The input file $data might still have or have not the header, thus it is checked.
The file "filtered_flagged.bed" however has no header, thus no check needs to be made.
@JannikHamp
Copy link
Collaborator Author

I changed the script. Thanks for finding this little bug

@renewiegandt renewiegandt changed the base branch from master to dev January 18, 2019 20:48
Copy link
Collaborator

@renewiegandt renewiegandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the numbers match now.

@renewiegandt renewiegandt merged commit 89bc089 into dev Jan 18, 2019
@renewiegandt renewiegandt deleted the JannikHamp-patch-4 branch March 26, 2019 13:13
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants