def update_sequence_title(_, entry, preloaded, upload_contents): if entry is None: return '' if preloaded is not None: protein = pr.read_fasta(file_path=preloaded)[entry] elif upload_contents is not None and preloaded is None: data = '' try: content_type, content_string = upload_contents.split(',') data = base64.b64decode(content_string).decode('UTF-8') except AttributeError: pass if data == '': return '' protein = pr.read_fasta(data_string=data)[entry] else: return '' titles = ['name', 'entry name', 'protein name', 'identifier', 'desc-0'] for t in titles: try: return protein['description'][t] except KeyError: continue return ''
def update_protein_options(upload_contents, preloaded): dropdown_options = [ {'label': 1, 'value': 0} ] if preloaded is not None: proteins = pr.read_fasta(file_path=preloaded) elif upload_contents is not None and preloaded is None: data = '' try: content_type, content_string = upload_contents.split(',') data = base64.b64decode(content_string).decode('UTF-8') except AttributeError: pass proteins = pr.read_fasta(data_string=data) else: return dropdown_options if isinstance(proteins, list): dropdown_options = [] for i in range(len(proteins)): dropdown_options.append(dict( label=i+1, value=i )) return dropdown_options
def update_desc_info(upload_contents, entry, preloaded): if entry is None: return 'Please select an entry.' if preloaded is not None: protein = pr.read_fasta(file_path=preloaded)[entry] elif upload_contents is not None and preloaded is None: data = '' try: content_type, content_string = upload_contents.split(',') data = base64.b64decode(content_string).decode('UTF-8') except AttributeError: pass if data == '': return [] try: protein = pr.read_fasta(data_string=data)[entry] except Exception: return ['NA'] else: return 'Please either upload a file or select one from \ the dropdown.' desc = [] for key in protein['description']: tmp = key.title() + ': ' if 'desc-' not in key else '-' tmp += protein['description'][key] desc.append(tmp) desc.append(html.Br()) return desc
def update_sequence(upload_contents, entry, preloaded): if entry is None: return '' if preloaded is not None: protein = pr.read_fasta(file_path=preloaded)[entry] elif upload_contents is not None and preloaded is None: data = '' try: content_type, content_string = upload_contents.split(',') data = base64.b64decode(content_string).decode('UTF-8') except AttributeError: pass if data == '': return '-' protein = pr.read_fasta(data_string=data)[entry] else: return '-' return protein['sequence']