47 size_t num_cols = sedims[1];
49 const std::string type_name =
"single_cell_experiment";
50 const auto& scemap = internal_json::extract_typed_object_from_metadata(metadata.
other, type_name);
52 const std::string version_name =
"version";
53 const std::string& vstring = internal_json::extract_string_from_typed_object(scemap, version_name, type_name);
54 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(),
true);
55 if (version.major != 1) {
56 throw std::runtime_error(
"unsupported version string '" + vstring +
"'");
60 auto rddir = path /
"reduced_dimensions";
61 if (std::filesystem::exists(rddir)) {
62 auto num_rd = internal_summarized_experiment::check_names_json(rddir);
64 for (
size_t i = 0; i < num_rd; ++i) {
65 auto rdname = std::to_string(i);
66 auto rdpath = rddir / rdname;
71 if (dims.size() < 1) {
72 throw std::runtime_error(
"object in 'reduced_dimensions/" + rdname +
"' should have at least one dimension");
74 if (dims[0] != num_cols) {
75 throw std::runtime_error(
"object in 'reduced_dimensions/" + rdname +
"' should have the same number of rows as the columns of its parent '" + metadata.
type +
"'");
79 size_t num_dir_obj = internal_other::count_directory_entries(rddir);
80 if (num_dir_obj - 1 != num_rd) {
81 throw std::runtime_error(
"more objects than expected inside the 'reduced_dimensions' subdirectory");
86 auto aedir = path /
"alternative_experiments";
87 std::unordered_set<std::string> alt_names;
88 if (std::filesystem::exists(aedir)) {
89 internal_summarized_experiment::check_names_json(aedir, alt_names);
90 size_t num_ae = alt_names.size();
92 for (
size_t i = 0; i < num_ae; ++i) {
93 auto aename = std::to_string(i);
94 auto aepath = aedir / aename;
97 throw std::runtime_error(
"object in 'alternative_experiments/" + aename +
"' should satisfy the 'SUMMARIZED_EXPERIMENT' interface");
102 if (dims[1] != num_cols) {
103 throw std::runtime_error(
"object in 'alternative_experiments/" + aename +
"' should have the same number of columns as its parent '" + metadata.
type +
"'");
107 size_t num_dir_obj = internal_other::count_directory_entries(aedir);
108 if (num_dir_obj - 1 != num_ae) {
109 throw std::runtime_error(
"more objects than expected inside the 'alternative_experiments' subdirectory");
114 auto mIt = scemap.find(
"main_experiment_name");
115 if (mIt != scemap.end()) {
116 const auto& ver = mIt->second;
117 if (ver->type() != millijson::STRING) {
118 throw std::runtime_error(
"expected 'main_experiment_name' to be a string");
120 const auto& mname =
reinterpret_cast<const millijson::String*
>(ver.get())->value;
122 throw std::runtime_error(
"expected 'main_experiment_name' to be a non-empty string");
124 if (alt_names.find(mname) != alt_names.end()) {
125 throw std::runtime_error(
"expected 'main_experiment_name' to not overlap with 'alternative_experiment' names (found '" + mname +
"')");
bool satisfies_interface(const std::string &type, const std::string &interface, const Options &options)
Definition _satisfies_interface.hpp:67
void validate(const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options)
Definition _validate.hpp:107
std::vector< size_t > dimensions(const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options)
Definition _dimensions.hpp:69