def index(): folder_path = var.music_folder files = util.get_recursive_filelist_sorted(var.music_folder) music_library = util.Dir(folder_path) for file in files: music_library.add_file(file) return render_template('index.html', all_files=files, music_library=music_library, os=os, playlist=var.playlist, user=var.user, paused=var.botamusique.is_pause)
p.add_argument('--merge_bams', action='store_true', help='If files need to be merged') p.add_argument('-T', '--tmp', metavar='DIR', required=True, help='The TMP directory for storing intermediate files (default=output directory') p.add_argument('--id',metavar='STR', required=True, help="sample id") p.add_argument('--lb',metavar='STR', required=True, help="library") p.add_argument('--sm',metavar='STR', required=True, help="sample name (will creat such a folder in TMP dir to hold temp files)") p.add_argument('--pl',metavar='STR', required=True, help="sequencing platform") p.add_argument('-j', '--jobfile', metavar='FILE', help='The jobfile name (default: stdout)') p.add_argument('-m', '--memory', metavar='SIZE', type=int, default=12, help='Memory size (GB) per job (default: 12)') p.add_argument('-p', '--project', metavar='NAME', default="CompBio", help='Project name for jobs (default: CompBio)') p.add_argument('-q', '--queue', metavar='NAME', default="normal", help='Queue for jobs (default: normal)') p.add_argument('-t', '--threads', metavar='COUNT', type=int, default=4, help='Number of threads for BWA alignment, only works for SGE (default: 4)') p.add_argument('--account', metavar='STR', default="swang", help='Accounting string for the purpose of cluster accounting.') p.add_argument('--submit', action='store_true', help='Submit the jobs') args = p.parse_args() outdir=util.Dir(args.outdir) outdir.mkdirs() tmpdir=util.Dir(os.path.join(args.tmp, args.sm)) tmpdir.mkdirs() if args.jobfile is None: jobfile=None else: jobfile=util.File(args.jobfile) readgroup = "'@RG\\\\tID:%s\\\\tLB:%s\\\\tSM:%s\\\\tPL:%s'" % (args.id, args.lb, args.sm, args.pl) sjm.Job.name_prefix="BWA-mapping"+"." sjm.Job.memory="%sG"%args.memory sjm.Job.queue="pcgp"
def post(): folder_path = var.music_folder if request.method == 'POST': logging.debug("Post request: " + str(request.form)) if 'add_file_bottom' in request.form and ".." not in request.form[ 'add_file_bottom']: path = var.config.get( 'bot', 'music_folder') + request.form['add_file_bottom'] if os.path.isfile(path): item = { 'type': 'file', 'path': request.form['add_file_bottom'], 'title': '', 'user': '******' } var.playlist.append(util.get_music_tag_info(item)) logging.info('web: add to playlist(bottom): ' + item['path']) elif 'add_file_next' in request.form and ".." not in request.form[ 'add_file_next']: path = var.config.get( 'bot', 'music_folder') + request.form['add_file_next'] if os.path.isfile(path): item = { 'type': 'file', 'path': request.form['add_file_next'], 'title': '', 'user': '******' } var.playlist.insert(var.playlist.current_index + 1, util.get_music_tag_info(item)) logging.info('web: add to playlist(next): ' + item['path']) elif ('add_folder' in request.form and ".." not in request.form['add_folder']) or ( 'add_folder_recursively' in request.form and ".." not in request.form['add_folder_recursively']): try: folder = request.form['add_folder'] except: folder = request.form['add_folder_recursively'] if not folder.endswith('/'): folder += '/' print('folder:', folder) if os.path.isdir(var.config.get('bot', 'music_folder') + folder): files = util.get_recursive_filelist_sorted(var.music_folder) music_library = util.Dir(folder_path) for file in files: music_library.add_file(file) if 'add_folder_recursively' in request.form: files = music_library.get_files_recursively(folder) else: files = music_library.get_files(folder) files = list( map( lambda file: util.get_music_tag_info( { 'type': 'file', 'path': os.path.join(folder, file), 'user': '******' }), files)) for file in files: logging.info("web: add to playlist: %s" % file['path']) var.playlist.extend(files) elif 'add_url' in request.form: music = { 'type': 'url', 'url': request.form['add_url'], 'user': '******', 'ready': 'validation' } media.url.get_url_info(music) var.playlist.append(music) logging.info("web: add to playlist: " + request.form['add_url']) var.playlist.playlist[-1]['ready'] = "no" elif 'add_radio' in request.form: var.playlist.append({ 'type': 'radio', 'path': request.form['add_radio'], 'user': "******" }) logging.info("web: add to playlist: " + request.form['add_radio']) elif 'delete_music' in request.form: music = var.playlist.playlist[int(request.form['delete_music'])] logging.info( "web: delete from playlist: " + str(music['path'] if 'path' in music else music['url'])) if var.playlist.length() >= int(request.form['delete_music']): if int(request.form['delete_music'] ) == var.playlist.current_index: var.playlist.remove(int(request.form['delete_music'])) var.botamusique.stop() var.botamusique.launch_music( int(request.form['delete_music'])) else: var.playlist.remove(int(request.form['delete_music'])) elif 'play_music' in request.form: music = var.playlist.playlist[int(request.form['play_music'])] logging.info( "web: jump to: " + str(music['path'] if 'path' in music else music['url'])) if len(var.playlist.playlist) >= int(request.form['play_music']): var.botamusique.stop() var.botamusique.launch_music(int(request.form['play_music'])) elif 'delete_music_file' in request.form and ".." not in request.form[ 'delete_music_file']: path = var.config.get( 'bot', 'music_folder') + request.form['delete_music_file'] if os.path.isfile(path): logging.info("web: delete file " + path) os.remove(path) elif 'delete_folder' in request.form and ".." not in request.form[ 'delete_folder']: path = var.config.get( 'bot', 'music_folder') + request.form['delete_folder'] if os.path.isdir(path): logging.info("web: delete folder " + path) shutil.rmtree(path) time.sleep(0.1) elif 'action' in request.form: action = request.form['action'] if action == "randomize": var.botamusique.stop() var.playlist.randomize() var.botamusique.resume() elif action == "stop": var.botamusique.stop() elif action == "pause": var.botamusique.pause() elif action == "resume": var.botamusique.resume() elif action == "clear": var.botamusique.clear() elif action == "volume_up": if var.botamusique.volume_set + 0.03 < 1.0: var.botamusique.volume_set = var.botamusique.volume_set + 0.03 else: var.botamusique.volume_set = 1.0 logging.info("web: volume up to %d" % (var.botamusique.volume_set * 100)) elif action == "volume_down": if var.botamusique.volume_set - 0.03 > 0: var.botamusique.volume_set = var.botamusique.volume_set - 0.03 else: var.botamusique.volume_set = 0 logging.info("web: volume up to %d" % (var.botamusique.volume_set * 100)) if (var.playlist.length() > 0): return jsonify({ 'ver': var.playlist.version, 'empty': False, 'play': not var.botamusique.is_pause }) else: return jsonify({ 'ver': var.playlist.version, 'empty': True, 'play': False })
def index(): folder_path = var.music_folder files = util.get_recursive_filelist_sorted(var.music_folder) music_library = util.Dir(folder_path) for file in files: music_library.add_file(file) if request.method == 'POST': print(request.form) if 'add_file' in request.form and ".." not in request.form['add_file']: item = {'type': 'file', 'path' : request.form['add_file'], 'user' : 'Web'} var.playlist.append(item) elif ('add_folder' in request.form and ".." not in request.form['add_folder']) or ('add_folder_recursively' in request.form and ".." not in request.form['add_folder_recursively']): try: folder = request.form['add_folder'] except: folder = request.form['add_folder_recursively'] if not folder.endswith('/'): folder += '/' print('folder:', folder) if 'add_folder_recursively' in request.form: files = music_library.get_files_recursively(folder) else: files = music_library.get_files(folder) files = list(map(lambda file: {'type':'file','path': os.path.join(folder, file), 'user':'******'}, files)) print('Adding to playlist: ', files) var.playlist.extend(files) elif 'add_url' in request.form: var.playlist.append({'type':'url', 'url': request.form['add_url'], 'user': '******', 'ready': 'validation'}) media.url.get_url_info() var.playlist[-1]['ready'] = "no" elif 'add_radio' in request.form: var.playlist.append({'type': 'radio', 'path': request.form['add_radio'], 'user': "******"}) elif 'delete_music' in request.form: if len(var.playlist) >= request.form['delete_music']: var.playlist.pop(request.form['delete_music']) elif 'action' in request.form: action = request.form['action'] if action == "randomize": random.shuffle(var.playlist) return render_template('index.html', all_files=files, music_library=music_library, os=os, playlist=var.playlist, user=var.user)
help='Final single vcf output file if choose joint call') g2.add_argument('--skip_realn_recal', action='store_true', help='Skip GATK relingment and recalibration') g2.add_argument('--skip_recal', action='store_true', help='Skip GATK recalibration only') p.add_argument('--submit', action='store_true', help='Submit the jobs') args = p.parse_args() if args.jobfile is None: jobfile = None else: jobfile = util.File(args.jobfile) outdir = util.Dir(args.output) logdir = util.Dir(outdir, 'log') tmpdir = outdir if args.tmp: tmpdir = util.Dir(args.tmp) tmpdir.mkdirs() outdir.mkdirs() sjm.Job.name_prefix = "GATK" + "." sjm.Job.memory = "20G" sjm.Job.queue = "pcgp" sjm.Job.project = "CompBio" if args.account: sjm.Job.sge_options = "-A %s" % args.account tmpdir = getattr(__builtins__, 'str')(tmpdir) outdir = getattr(__builtins__, 'str')(outdir)
'--temp_prefix', metavar='NAME', required=True, help='The merged gvcf file prefix') p.add_argument('-T', '--tempdir', metavar='DIR', required=True, help='The directory to hold merged gvcfs') p.add_argument('-j', '--jobfile', metavar='FILE', help='The jobfile name (default: stdout)') args = p.parse_args() outdir = util.Dir(args.outdir) outdir.mkdirs() tmpdir = util.Dir(args.tempdir) tmpdir.mkdirs() if args.jobfile is None: jobfile = None else: jobfile = util.File(args.jobfile) sjm.Job.name_prefix = "GATK-joint" + "." sjm.Job.memory = "12G" sjm.Job.queue = "pcgp" sjm.Job.project = "CompBio" outdir = getattr(__builtins__, 'str')(outdir)
p.add_argument( '-t', '--threads', metavar='COUNT', type=int, default=4, help='Number of threads for BWA alignment, only works for SGE (default: 4)' ) p.add_argument('--account', metavar='STR', default="swang", help='Accounting string for the purpose of cluster accounting.') p.add_argument('--submit', action='store_true', help='Submit the jobs') args = p.parse_args() outdir = util.Dir(args.outdir) outdir.mkdirs() tmplett = ''.join(random.sample(string.ascii_letters, 6)) tmpdir = util.Dir(os.path.join(args.tmp, tmplett)) tmpdir.mkdirs() if args.jobfile is None: jobfile = None else: jobfile = util.File(args.jobfile) sjm.Job.name_prefix = "BWA-mapping" + "." sjm.Job.memory = "%sG" % args.memory sjm.Job.queue = "pcgp" sjm.Job.project = "CompBio"
def cmd_play_file(bot, user, text, command, parameter): music_folder = var.config.get('bot', 'music_folder') # if parameter is {index} if parameter.isdigit(): files = util.get_recursive_filelist_sorted(music_folder) if int(parameter) < len(files): filename = files[int(parameter)].replace(music_folder, '') music = {'type': 'file', 'path': filename, 'user': user} logging.info("cmd: add to playlist: " + filename) var.playlist.append(music) bot.send_msg(var.config.get('strings', 'file_added') + music['title'], text) # if parameter is {path} else: # sanitize "../" and so on path = os.path.abspath(os.path.join(music_folder, parameter)) if not path.startswith(os.path.abspath(music_folder)): bot.send_msg(var.config.get('strings', 'no_file'), text) return if os.path.isfile(path): music = {'type': 'file', 'path': parameter, 'user': user} logging.info("cmd: add to playlist: " + parameter) music = var.playlist.append(music) bot.send_msg(var.config.get('strings', 'file_added') + music['title'], text) return # if parameter is {folder} elif os.path.isdir(path): if parameter != '.' and parameter != './': if not parameter.endswith("/"): parameter += "/" else: parameter = "" files = util.get_recursive_filelist_sorted(music_folder) music_library = util.Dir(music_folder) for file in files: music_library.add_file(file) files = music_library.get_files(parameter) msgs = [var.config.get('strings', 'file_added')] count = 0 for file in files: count += 1 music = {'type': 'file', 'path': file, 'user': user} logging.info("cmd: add to playlist: " + file) music = var.playlist.append(music) msgs.append("{} ({})".format(music['title'], music['path'])) if count != 0: send_multi_lines(bot, msgs, text) else: bot.send_msg(var.config.get('strings', 'no_file'), text) else: # try to do a partial match files = util.get_recursive_filelist_sorted(music_folder) matches = [(index, file) for index, file in enumerate(files) if parameter.lower() in file.lower()] if len(matches) == 0: bot.send_msg(var.config.get( 'strings', 'no_file'), text) elif len(matches) == 1: music = {'type': 'file', 'path': matches[0][1], 'user': user} logging.info("cmd: add to playlist: " + matches[0][1]) music = var.playlist.append(music) bot.send_msg(var.config.get( 'strings', 'file_added') + "{} ({})".format(music['title'], music['path']), text) else: msgs = [ var.config.get('strings', 'multiple_matches') ] for match in matches: msgs.append("<b>{:0>3d}</b> - {:s}".format(match[0], match[1])) send_multi_lines(bot, msgs, text)