Esempio n. 1
0
async def show_messages(message, args):
    channels = find_channel_mentions_in_message(message, args)
    for channel in channels:
        limit = int(args[0]) if args else 10
        messages = await channel.history(limit=limit).flatten()
        shorten_size = int(args[1]) if len(args) > 1 else 50
        msg = format_list([format_message(msg, shorten_size=shorten_size) for msg in messages])
        await long_send(message.channel, msg, quotes=False)
Esempio n. 2
0
if __name__ == '__main__':
    start = time.time()
    parser = argparse.ArgumentParser('....')
    parser.add_argument('--sample',
                        default=False,
                        action='store_true',
                        help='process sample dataset')
    parser.add_argument('--rosalind',
                        default=False,
                        action='store_true',
                        help='process Rosalind dataset')
    args = parser.parse_args()
    if args.sample:
        for line in itwv('GACCACGGTT', ['ACAG', 'GT', 'CCG']):
            print(format_list(line))

    if args.rosalind:
        Input = read_strings(
            f'data/rosalind_{os.path.basename(__file__).split(".")[0]}.txt')

        Result = itwv(Input[0], Input[1:])
        with open(f'{os.path.basename(__file__).split(".")[0]}.txt', 'w') as f:
            for line in Result:
                out = format_list(line)
                f.write(f'{out}\n')

    elapsed = time.time() - start
    minutes = int(elapsed / 60)
    seconds = elapsed - 60 * minutes
    print(f'Elapsed Time {minutes} m {seconds:.2f} s')
Esempio n. 3
0
#    Copyright (C) 2019 Greenweaves Software Limited
#
#    This is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This software is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>

# BIP Testing Bipartiteness

from helpers import format_list, parse_graphs
from graphs import bip

if __name__ == '__main__':

    with open(r'C:\Users\Simon\Downloads\rosalind_bip(3).txt') as f:
        print(format_list([bip(g) for g in parse_graphs(f)]))
Esempio n. 4
0
#
#    This is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This software is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>
#
#    TS Topological  sort

from align import topological_order
from helpers import parse_graph, create_adjacency, format_list

if __name__ == '__main__':
    with open(r'C:\Users\Simon\Downloads\rosalind_ts.txt') as f:
        g = parse_graph(f)

        _, _, adj = create_adjacency(g, back=False)
        for k, v in adj.items():
            if k in v:
                v.remove(k)

        t = topological_order(adj)
        print(format_list(t))