def _get_seqs_data(raw_seqs): raw_seqs = _fix_string_newlines(unicode(raw_seqs)) # This patch is required for some reason, because Django somehow corrupts uploaded files LOGGER.info('Received a %d bytes long FASTA' % len(raw_seqs)) seqs_fasta = StringIO(_fix_fasta_if_needed(raw_seqs)) records = list(SeqIO.parse(seqs_fasta, 'fasta')) LOGGER.info('About to process %d records' % len(records)) for record in records: id = record.id seq = str(record.seq) LOGGER.info('Processing record %s: %s' % (id, seq)) cleavage_mask, cleavage_products = simple_cleavage_predictor.predict(seq, proba = True) labeled_aa_chunks = split_to_chunks([_LabeledAminoAcid(aa, label) for aa, label in zip(seq, cleavage_mask)], _RESIDUES_TO_DISPAY_PER_ROW) yield id, labeled_aa_chunks, cleavage_products
def _get_seqs_data(raw_seqs): raw_seqs = _fix_string_newlines( unicode(raw_seqs) ) # This patch is required for some reason, because Django somehow corrupts uploaded files LOGGER.info('Received a %d bytes long FASTA' % len(raw_seqs)) seqs_fasta = StringIO(_fix_fasta_if_needed(raw_seqs)) records = list(SeqIO.parse(seqs_fasta, 'fasta')) LOGGER.info('About to process %d records' % len(records)) for record in records: id = record.id seq = str(record.seq) LOGGER.info('Processing record %s: %s' % (id, seq)) cleavage_mask, cleavage_products = simple_cleavage_predictor.predict( seq, proba=True) labeled_aa_chunks = split_to_chunks([ _LabeledAminoAcid(aa, label) for aa, label in zip(seq, cleavage_mask) ], _RESIDUES_TO_DISPAY_PER_ROW) yield id, labeled_aa_chunks, cleavage_products
def space_seq(seq, chunk_length=10): return ' '.join(util.split_to_chunks(seq, chunk_length))
def space_seq(seq, chunk_length = 10): return ' '.join(util.split_to_chunks(seq, chunk_length))