Skip to content

Commit

Permalink
fix bug; support Proteinortho6
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangrengang committed Oct 24, 2024
1 parent 438c1d7 commit 288b05d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ Tetracendron_sinense|Tesin01G0062600 Trochodendron_aralioides|evm.TU.group9.7

#### Orthology format ####
The outputs from [OrthoFinder2](https://github.com/davidemms/OrthoFinder), OrthoMCL,
[Proteinortho6](https://gitlab.com/paulklemm_PHD/proteinortho),
[Broccoli](https://github.com/rderelle/Broccoli), [SonicParanoid2](https://gitlab.com/salvo981/sonicparanoid2) are supported:
```
# OrthoFinder2 output directory like:
Expand Down
18 changes: 13 additions & 5 deletions soi/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#from reportlab.lib import colors
import numpy as np
from matplotlib import cm
from matplotlib import colors
import matplotlib

COLORS_HEX = ['#f9c00c', '#00b9f1', '#7200da', '#f9320c', '#00b8a9', "#F4A460", '#009999', '#00C02E',
Expand All @@ -20,8 +21,9 @@ def __init__(self, colors_hex=None):
self.colors_hex = colors_hex
@property
def colors_rgb(self):
colors_lst = [colors.HexColor(v) for v in self.colors_hex]
return [','.join(map(str, v.bitmap_rgb())) for v in colors_lst]
# colors_lst = [colors.HexColor(v) for v in self.colors_hex]
# return [','.join(map(str, v.bitmap_rgb())) for v in colors_lst]
return [hex2rgb(v) for v in self.colors_hex]
@property
def colors_r(self):
return 'c({})'.format(','.join(map(repr, self.colors_hex)))
Expand All @@ -30,6 +32,11 @@ def __str__(self):
def __repr__(self):
return str(self.colors_hex)

def hex2rgb(Hex):
rgb = colors.to_rgb(Hex)
rgb255 = ','.join(map(str, [int(v*255) for v in rgb]))
return rgb255

class Colors:
def __init__(self, n):
self.n = n
Expand All @@ -48,9 +55,10 @@ def to_hex(self):
colors_hex = [matplotlib.colors.to_hex(c) for c in self.colors]
return colors_hex
def to_rgb(self):
colors_hex = self.to_hex()
colors_lst = [colors.HexColor(v) for v in colors_hex]
colors_rgb = [','.join(map(str, v.bitmap_rgb())) for v in colors_lst]
# colors_hex = self.to_hex()
# colors_lst = [colors.HexColor(v) for v in colors_hex]
# colors_rgb = [','.join(map(str, v.bitmap_rgb())) for v in colors_lst]
colors_rgb = [hex2rgb(v) for v in self.colors]
return colors_rgb


2 changes: 1 addition & 1 deletion soi/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def plot_eval(d_rcs, outfig, legend_fontsize=9):
ncols = n // 30 + 1
ax0.set_xlim(0,1)
ax0.set_ylim(0,1)
ax0.legend(loc=(-1.5, 0),fancybox=False, frameon=False, ncols=ncols)
ax0.legend(loc=(-1.5, 0),fancybox=False, frameon=False, ncols=ncols) #
ax0.xaxis.set_tick_params(length=0)
ax0.spines['right'].set_color('none')
ax0.spines['top'].set_color('none')
Expand Down
4 changes: 3 additions & 1 deletion soi/mcscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ def slim_tandem(tandem, pairs, outPairs):
pair.write(outPairs)

def split_pair(line, sep=None, parser=None):
pair = tuple(line.rstrip().split(sep, 1))
pair = tuple(line.rstrip().split(sep)) # 1
return parser(*pair)

class CommonPair(object):
Expand Down Expand Up @@ -1186,6 +1186,8 @@ def __iter__(self):
def _parse(self):
for line in open(self.pairs):
line = lazy_decode(line)
if line.startswith('#'): # comments
continue
yield split_pair(line, self.sep, self.parser)
def graph(self):
G = nx.Graph()
Expand Down

0 comments on commit 288b05d

Please sign in to comment.