From b156f90ea05cdece39db52f07d7dcc567ea540db Mon Sep 17 00:00:00 2001 From: stijndcl Date: Thu, 31 Mar 2022 20:03:00 +0200 Subject: [PATCH 1/4] fixes #109 --- cogs/help.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cogs/help.py b/cogs/help.py index 598a8de..5f32786 100644 --- a/cogs/help.py +++ b/cogs/help.py @@ -50,7 +50,16 @@ class HelpCommand(commands.MinimalHelpCommand): return await self.send_bot_help(self.get_bot_mapping()) # Turn dic to lowercase to allow proper name searching - all_commands = dict((k.lower(), v) for k, v in bot.all_commands.items() if not isinstance(v, SlashCommand)) + all_commands = {} + + for k, v in bot.all_commands.items(): + if k is None or v is None: + continue + + if isinstance(v, SlashCommand): + continue + + all_commands[k.lower()] = v if spl[0].lower() not in all_commands: return await self.send_error_message(await self.command_not_found(spl[0])) From 0151913e618e1d53d08f639cb20b5bb1663d1466 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Thu, 31 Mar 2022 20:12:18 +0200 Subject: [PATCH 2/4] Update compbio leaderboard to assignment 4 --- .gitignore | 1 + cogs/slash/school_slash.py | 5 +++-- data/menus/leaderboards.py | 18 ++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index df503ea..4784e9c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ files/lost.json files/locked.json files/ufora_notifications.json files/compbio_benchmarks_2.json +files/compbio_benchmarks_4.json .idea/ __pycache__ .env diff --git a/cogs/slash/school_slash.py b/cogs/slash/school_slash.py index 3b6df67..c26f61b 100644 --- a/cogs/slash/school_slash.py +++ b/cogs/slash/school_slash.py @@ -91,9 +91,10 @@ class SchoolSlash(commands.Cog): @_compbio_group.command(name="leaderboard", description="Gesorteerd en ingevuld leaderboard") async def _compbio_lb_slash(self, ctx: ApplicationContext, - benchmark: Option(int, "De specifieke benchmark om op te halen (default k=600)", choices=[6, 10, 50, 600], default=600)): + benchmark: Option(str, "De specifieke benchmark om op te halen (default 10000-10)", choices=["100-10", "100-100", "1000-100", "10000-10"], default="10000-10")): await ctx.response.defer() - lb = leaderboards.CompbioLeaderboard(ctx, kmer=benchmark) + size, amount = benchmark.split("-") + lb = leaderboards.CompbioLeaderboard(ctx, size=size, amount=amount) await lb.respond() @_compbio_group.command(name="submit", description="Link een Dodona-submission aan jouw username") diff --git a/data/menus/leaderboards.py b/data/menus/leaderboards.py index af97e18..1680568 100644 --- a/data/menus/leaderboards.py +++ b/data/menus/leaderboards.py @@ -123,16 +123,17 @@ class BitcoinLeaderboard(Leaderboard): @dataclass class CompbioLeaderboard(Leaderboard): colour: discord.Colour = field(default=discord.Colour.green()) - title: str = field(default="Leaderboard Computationele Biologie #2") + title: str = field(default="Leaderboard Computationele Biologie #4") reverse: bool = False - kmer: int = 600 + size: int = 10000 + amount: int = 10 def __post_init__(self): - self.title += f" (k = {self.kmer})" + self.title += f" ({self.size}-{self.amount})" super().__post_init__() def get_submission_user(self, submission_id: str) -> str: - with open("files/compbio_benchmarks_2.json", "r") as fp: + with open("files/compbio_benchmarks_4.json", "r") as fp: file = json.load(fp) if submission_id in file: @@ -142,14 +143,7 @@ class CompbioLeaderboard(Leaderboard): return f"[# {submission_id}]" def get_data(self) -> list[tuple]: - files = { - 6: "J02459.1", - 10: "J02459.1", - 50: "J02459.1", - 600: "AF033819.3" - } - - url = f"https://github.ugent.be/raw/computationele-biologie/benchmarks-2022/main/reconstruction/{files[self.kmer]}.{self.kmer}mers.md" + url = f"https://github.ugent.be/raw/computationele-biologie/benchmarks-2022/tree/main/profile_hmm/size{self.size}-amount{self.amount}.md" headers = {"Authorization": f"token {settings.UGENT_GH_TOKEN}"} result = requests.get(url, headers=headers).text From 8e050f9ab3a7d620e9e7b03fce1a7195c6936ac8 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Thu, 31 Mar 2022 20:12:44 +0200 Subject: [PATCH 3/4] Update compbio leaderboard to assignment 4 --- cogs/slash/school_slash.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/slash/school_slash.py b/cogs/slash/school_slash.py index c26f61b..60a8657 100644 --- a/cogs/slash/school_slash.py +++ b/cogs/slash/school_slash.py @@ -102,7 +102,7 @@ class SchoolSlash(commands.Cog): submission: Option(int, description="Id van je Dodona indiening.", required=True)): await ctx.response.defer(ephemeral=True) - with open("files/compbio_benchmarks_2.json", "r") as fp: + with open("files/compbio_benchmarks_4.json", "r") as fp: file = json.load(fp) submission = str(submission) @@ -110,7 +110,7 @@ class SchoolSlash(commands.Cog): if submission in file: return await ctx.send_followup("❌ Deze submission is al aan iemand gelinkt.") - with open("files/compbio_benchmarks_2.json", "w") as fp: + with open("files/compbio_benchmarks_4.json", "w") as fp: file[submission] = ctx.user.id json.dump(file, fp) From 97d533e04f01ea6b3ce139b1d67ff9502c7f2a76 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Thu, 31 Mar 2022 20:21:34 +0200 Subject: [PATCH 4/4] Fix url --- data/menus/leaderboards.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/menus/leaderboards.py b/data/menus/leaderboards.py index 1680568..1a912db 100644 --- a/data/menus/leaderboards.py +++ b/data/menus/leaderboards.py @@ -143,7 +143,7 @@ class CompbioLeaderboard(Leaderboard): return f"[# {submission_id}]" def get_data(self) -> list[tuple]: - url = f"https://github.ugent.be/raw/computationele-biologie/benchmarks-2022/tree/main/profile_hmm/size{self.size}-amount{self.amount}.md" + url = f"https://github.ugent.be/raw/computationele-biologie/benchmarks-2022/main/profile_hmm/size{self.size}-amount{self.amount}.md" headers = {"Authorization": f"token {settings.UGENT_GH_TOKEN}"} result = requests.get(url, headers=headers).text