File: Reader.cpp

package info (click to toggle)
ausaxs 1.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 72,592 kB
  • sloc: cpp: 49,853; ansic: 6,901; python: 730; makefile: 18
file content (29 lines) | stat: -rw-r--r-- 1,273 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// SPDX-License-Identifier: LGPL-3.0-or-later
// Author: Kristian Lytje

#include <io/Reader.h>
#include <io/detail/structure/CIFReader.h>
#include <io/detail/structure/PDBReader.h>
#include <io/detail/structure/XYZReader.h>
#include <io/ExistingFile.h>
#include <utility/Exceptions.h>
#include <utility/StringUtils.h>

using namespace ausaxs;

io::pdb::PDBStructure io::Reader::read(const io::File& path) {
    auto ext = utility::to_lowercase(path.extension());
    if (path.extension() == ".xml" || path.extension() == ".XML") { // .xml PDBStructure
        throw except::invalid_argument("PDBStructure::construct_reader: .xml input PDBStructures are not supported.");
    } else if (ext == ".pdb") { // .pdb structure
        return io::detail::pdb::read(path);
    } else if (ext == ".ent") { // .ent structure
        return io::detail::pdb::read(path);
    } else if (ext == ".cif") { // .cif structure
        return io::detail::cif::read(path);
    } else if (ext == ".xyz") { // .xyz structure
        return io::detail::xyz::read(path);
    } else { // anything else - we cannot handle this
        throw except::invalid_argument("PDBStructure::construct_reader: Unsupported extension \"" + path.extension() + "\" of input file \"" + path.str() + "\".");
    }
}