def as_fasta(record): """Turn a SeqRecord into a FASTA formated string. This is used internally by the SeqRecord's .format("fasta") method and by the SeqIO.write(..., ..., "fasta") function. """ id = _clean(record.id) description = _clean(record.description) if description and description.split(None, 1)[0] == id: # The description includes the id at the start title = description elif description: title = "%s %s" % (id, description) else: title = id assert "\n" not in title assert "\r" not in title lines = [">%s\n" % title] data = _get_seq_string(record) # Catches sequence being None assert "\n" not in data assert "\r" not in data for i in range(0, len(data), 60): lines.append(data[i : i + 60] + "\n") return "".join(lines)
def as_fasta(record): """Turn a SeqRecord into a FASTA formated string. This is used internally by the SeqRecord's .format("fasta") method and by the SeqIO.write(..., ..., "fasta") function. """ id = _clean(record.id) description = _clean(record.description) if description and description.split(None, 1)[0] == id: # The description includes the id at the start title = description elif description: title = "%s %s" % (id, description) else: title = id assert "\n" not in title assert "\r" not in title lines = [">%s\n" % title] data = _get_seq_string(record) # Catches sequence being None assert "\n" not in data assert "\r" not in data for i in range(0, len(data), 60): lines.append(data[i:i + 60] + "\n") return "".join(lines)
def as_tab(record): title = _clean(record.id) seq = _get_seq_string(record) # Catches sequence being None assert "\t" not in title assert "\n" not in title assert "\r" not in title assert "\t" not in seq assert "\n" not in seq assert "\r" not in seq return "%s\t%s\n" % (title, seq)
def as_tab(record): """Return record as tab separated (id(tab)seq) string.""" title = _clean(record.id) seq = _get_seq_string(record) # Catches sequence being None assert "\t" not in title assert "\n" not in title assert "\r" not in title assert "\t" not in seq assert "\n" not in seq assert "\r" not in seq return "%s\t%s\n" % (title, seq)
def as_tab(record): """Return record as tab separated (id(tab)seq) string.""" title = _clean(record.id) seq = _get_seq_string(record) # Catches sequence being None assert "\t" not in title assert "\n" not in title assert "\r" not in title assert "\t" not in seq assert "\n" not in seq assert "\r" not in seq return "%s\t%s\n" % (title, seq)
def as_fasta_2line(record): """Turn a SeqRecord into a two-line FASTA formated string. This is used internally by the SeqRecord's .format("fasta-2line") method and by the SeqIO.write(..., ..., "fasta-2line") function. """ id = _clean(record.id) description = _clean(record.description) if description and description.split(None, 1)[0] == id: # The description includes the id at the start title = description elif description: title = "%s %s" % (id, description) else: title = id assert "\n" not in title assert "\r" not in title data = _get_seq_string(record) # Catches sequence being None assert "\n" not in data assert "\r" not in data return ">%s\n%s\n" % (title, data)
def as_fasta_2line(record): """Turn a SeqRecord into a two-line FASTA formated string. This is used internally by the SeqRecord's .format("fasta-2line") method and by the SeqIO.write(..., ..., "fasta-2line") function. """ id = _clean(record.id) description = _clean(record.description) if description and description.split(None, 1)[0] == id: # The description includes the id at the start title = description elif description: title = "%s %s" % (id, description) else: title = id assert "\n" not in title assert "\r" not in title data = _get_seq_string(record) # Catches sequence being None assert "\n" not in data assert "\r" not in data return ">%s\n%s\n" % (title, data)