# Input/Output in files — `pbxplore.io`

Deals with writing and reading of files in various formats.

## Fasta

`pbxplore.io.``read_fasta`(name)

  Read fasta file and output sequences in a list.

  Parameters: | name (str) – Name of file containing sequences in fasta format.
  Returns: | header_lst (list) – List of headers (str) sequence_lst (list) – List of sequences (str)

`pbxplore.io.``read_several_fasta`(input_files)

  Read several fasta files

  Note that each fasta file may contain several sequences.

  Parameters: | input_files (a list of fasta file paths.) –
  Returns: | pb_name (a list of the headers) pb_seq (a list of the sequences)

`pbxplore.io.``write_fasta`(outfile, sequences, comments)

  Write fasta entries (header + sequence) in an open file

  Parameters: | name (file descriptor) – The file descriptor to write in. It must allow writing. header_lst (list) – List of headers (str) sequence_lst (list) – List of sequences (str)

`pbxplore.io.``write_fasta_entry`(outfile, sequence, comment, width=60)

  Write a fasta entry (header + sequence) in an open file

  Parameters: | name (file descriptor) – The file descriptor to write in. It must allow writing. sequence (str) – Sequence to format. comment (str) – Comment to make header of sequence. width (int) – The width of a line. FASTA_WIDTH by default.

## Results af analyses

`pbxplore.io.``write_count_matrix`(pb_count, outfile, first=1)

  Write a PB occurence matrix in a file.

  Parameters: | pb_count (an occurence matrix as a 2D numpy array.) – outfile (an open file where to write the matrix.) – first (the residue number of the first position.) –

`pbxplore.io.``write_neq`(outfile, neq_array, residue_min=1, residue_max=None)

  Write the Neq matrix in an open file

  Parameters: | outfile (file descriptor) – The file descriptor to write in. It must allow writing. neq_array (numpy array) – a 1D array containing the neq values. residue_min (int) – the lower bound of residue frame residue_max (int) – the upper bound of residue frame