Bioinformatics Programming Using Python

Bioinformatics Programming Using Python

Chapter 6

Working with Text: textwrap

# Returns a copy of the string text with whitespace common to all of its lines re- moved
textwrap.dedent(text)

## useful in dealing with FASTA files
# break up seq to a list of 80-line strings 
textwrap.wrap(seq, 80)

# insert newlines every 80 characters
textwrap.fill(seq, 80)

Persistent Storage

The dbm module provides an interface to the Unix “(n)dbm” library. Dbm objects behave like mappings (dictionaries), except that keys and values are always strings.

  • 'r' Open existing database for reading only (default)
  • 'w' Open existing database for reading and writing
  • 'c' Open database for reading and writing, creating it if it doesn’t exist
  • 'n' Always create a new, empty database, open for reading and writing

你可能感兴趣的:(文本处理,python)