
.. _program_listing_file_cif++_pdb.hpp:

Program Listing for File pdb.hpp
================================

|exhale_lsh| :ref:`Return to documentation for file <file_cif++_pdb.hpp>` (``cif++/pdb.hpp``)

.. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS

.. code-block:: cpp

   /*-
    * SPDX-License-Identifier: BSD-2-Clause
    *
    * Copyright (c) 2023 NKI/AVL, Netherlands Cancer Institute
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions are met:
    *
    * 1. Redistributions of source code must retain the above copyright notice, this
    *    list of conditions and the following disclaimer
    * 2. Redistributions in binary form must reproduce the above copyright notice,
    *    this list of conditions and the following disclaimer in the documentation
    *    and/or other materials provided with the distribution.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
    * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
   
   #pragma once
   
   #include "cif++/file.hpp"
   
   #include <system_error>
   
   namespace cif::pdb
   {
   
   // PDB to mmCIF
   
   file read(const std::filesystem::path &file);
   
   file read(std::istream &is);
   
   file read_pdb_file(std::istream &pdbFile);
   
   // mmCIF to PDB
   
   void write(std::ostream &os, const datablock &db);
   
   inline void write(std::ostream &os, const file &f)
   {
       write(os, f.front());
   }
   
   void write(const std::filesystem::path &file, const datablock &db);
   
   inline void write(const std::filesystem::path &p, const file &f)
   {
       write(p, f.front());
   }
   
   // --------------------------------------------------------------------
   
   bool reconstruct_pdbx(file &pdbx_file, std::string_view dictionary = "mmcif_pdbx");
   
   bool is_valid_pdbx_file(const file &pdbx_file, std::string_view dictionary = "mmcif_pdbx");
   
   bool is_valid_pdbx_file(const file &pdbx_file, std::error_code &ec);
   
   bool is_valid_pdbx_file(const file &pdbx_file, std::string_view dictionary,
       std::error_code &ec);
   
   // --------------------------------------------------------------------
   // Other I/O related routines
   
   std::string get_HEADER_line(const datablock &data, std::string::size_type truncate_at = 127);
   std::string get_COMPND_line(const datablock &data, std::string::size_type truncate_at = 127);
   std::string get_SOURCE_line(const datablock &data, std::string::size_type truncate_at = 127);
   std::string get_AUTHOR_line(const datablock &data, std::string::size_type truncate_at = 127);
   
   } // namespace cif::pdb
