Closed ghuls closed 6 years ago
thanks @ghuls ! for the tip to help WebLogo users with controlling WebLogo formatting!
A better patch:
diff --git a/weblogolib/__init__.py b/weblogolib/__init__.py
index 7c8cdef..78b9e55 100755
--- a/weblogolib/__init__.py
+++ b/weblogolib/__init__.py
@@ -626,12 +626,15 @@ class LogoFormat(LogoOptions):
if self.show_yaxis:
self.line_margin_left = self.fontsize * 3.0
else:
- self.line_margin_left = 0
+ if self.show_ends and self.show_xaxis:
+ self.line_margin_left = self.fontsize * 1.5
+ else:
+ self.line_margin_left = 4
- if self.show_ends:
+ if self.show_ends and self.show_xaxis:
self.line_margin_right = self.fontsize * 1.5
else:
- self.line_margin_right = self.fontsize
+ self.line_margin_right = 4
# Current weblogo
./weblogo \
--sequence-type dna \
--datatype transfac \
--format png \
--color-scheme classic \
--fineprint '' \
--show-xaxis no \
--show-yaxis no \
--errorbars no \
--fin jaspar__MA0171.1.transfac \
--fout jaspar__MA0171.1.weblogo_unpatched.png
# Add border to see the difference:
convert -border 1 -bordercolor black jaspar__MA0171.1.weblogo_unpatched.png jaspar__MA0171.1.weblogo_unpatched.border.png
\
# Patched weblogo
./weblogo \
--sequence-type dna \
--datatype transfac \
--format png \
--color-scheme classic \
--fineprint '' \
--show-xaxis no \
--show-yaxis no \
--errorbars no \
--fin jaspar__MA0171.1.transfac \
--fout jaspar__MA0171.1.weblogo_patched.png
# Add border to see the difference:
convert -border 1 -bordercolor black jaspar__MA0171.1.weblogo_patched.png jaspar__MA0171.1.weblogo_patched.border.png
Unpatched logo:
Patched logo:
Thanks @ghuls ! Great work in keeping the logo centered with the patch. Appreciate the time and effort!
@go-bears Is it still a wontfix, or do you accept a pull request?
I removed the wontfix label @ghuls. If you add a test for your patch, I think it can be accepted as a PR.
@go-bears How can an add a test? Is there a method in https://github.com/WebLogo/weblogo/blob/master/test_weblogo.py, which I can mimic? And what exactly needs to be tested?
Pull request tested and accepted. Thanks.
thanks @ghuls for all your work!
If --show-yaxis is set to no, the left margin was set to zero, while the right margin was set to font_size.
If --show-ends is specified and --show-yaxis no, the left margin is now set to the same value as the right margin (fontsize * 1.5), so the logo is centered in the middle.
The following patch always centeres the logo if --show-yaxis no: