This repository was archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Metadata server #104
Merged
Merged
Metadata server #104
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
301643e
cmake libdbi changes and script to initialize metadata
9b00cd8
restructuring tests directory
0f4ed04
sql vid mapper - first cut
a83692b
temporary changes for tests
1764668
Merge branch 'master' into metadata_server
3f11a23
testing retrieval
3d491cd
printing out contigs in metadata loader tester
974b7b7
fixes suggested in review
a5e4d62
libdbi should be optional
8c89eff
file was somehow deleted
27d0764
installing dbi libs thro travis
cf55c30
reference query modified
faec345
incorporating changes suggested in code review
e79dd50
tentative code to load callsets info
c0b5860
modified callset query
107ce14
using google test
8f2b3b0
merged from master
b104f90
creating include directory for GTests
3f4af3d
changes recommended in code review
c6e1ee6
changes according to code review
38f6fe3
Merge branch 'master' into metadata_server
14af5d4
adding gtest to travis
a712fda
temp commit to verify gtest install
9a89695
building gtest for 14.04 since package doesnt exist for 14.04
6dab698
gtests will be run inside docker
f6eace7
fixing typo
ebde3f3
testing postgresql service
8a04962
testing psql in travis
2f2c500
restoring GTests
ce2411c
restoring GTests
f1ba868
restoring GTests
7a38909
restoring GTests
1ddfb53
trying to get gtests to run in travis
073e46f
Merge branch 'master' into metadata_server
cbaa64c
gtests
4de9eda
Merge branch 'metadata_server' of https://github.com/Intel-HLS/Genomi…
24ca93c
Tests finalized for now
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Determine compiler flags for libdbi | ||
| # Once done this will define | ||
| # LIBDBI_FOUND - libdbi found | ||
|
|
||
| find_path(LIBDBI_INCLUDE_DIR NAMES dbi.h HINTS "${LIBDBI_DIR}/include/dbi") | ||
|
|
||
| find_library(LIBPGSQL_DRIVER_LIBRARY NAMES dbdpgsql HINTS "${LIBDBI_DIR}/lib/${CMAKE_C_LIBRARY_ARCHITECTURE}/dbd") | ||
|
|
||
| find_library(LIBDBI_DEV_LIBRARY NAMES dbi HINTS "${LIBDBI_DIR}/lib/${CMAKE_C_LIBRARY_ARCHITECTURE}") | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
|
|
||
| find_package_handle_standard_args(libdbi "Could not find libdbi headers and/or libraries ${DEFAULT_MSG}" LIBDBI_INCLUDE_DIR LIBDBI_DEV_LIBRARY LIBPGSQL_DRIVER_LIBRARY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| add_subdirectory(resources) | ||
| add_subdirectory(main) | ||
| add_subdirectory(test) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ set(GenomicsDB_library_sources | |
| cpp/src/utils/lut.cc | ||
| cpp/src/utils/known_field_info.cc | ||
| cpp/src/utils/vid_mapper.cc | ||
| cpp/src/utils/vid_mapper_sql.cc | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if(LIBDBI_FOUND)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not necessary. There is a macro enveloping the code which prevents code from compiling
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, that's fine |
||
| cpp/src/utils/timer.cc | ||
| cpp/src/vcf/vcf_adapter.cc | ||
| cpp/src/vcf/genomicsdb_bcf_generator.cc | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * Copyright (c) 2016 Intel Corporation | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| * this software and associated documentation files (the "Software"), to deal in | ||
| * the Software without restriction, including without limitation the rights to | ||
| * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| * the Software, and to permit persons to whom the Software is furnished to do so, | ||
| * subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| */ | ||
| #ifdef LIBDBI | ||
| #ifndef GENOMICSDB_VID_MAPPER_SQL_H | ||
| #define GENOMICSDB_VID_MAPPER_SQL_H | ||
|
|
||
| #include "vid_mapper.h" | ||
| #include <string> | ||
| #include <vector> | ||
| #include <map> | ||
| #include <dbi/dbi.h> | ||
|
|
||
| const std::string PGSQL_DRIVER = "pgsql"; | ||
| const std::string DBCONN_HOST = "host"; | ||
| const std::string DBCONN_USERNAME = "username"; | ||
| const std::string DBCONN_PASSWORD = "password"; | ||
| const std::string DBCONN_DBNAME = "dbname"; | ||
| const std::string DBCONN_ENCODING = "encoding"; | ||
| const std::string UTF8_ENCODING = "UTF-8"; | ||
|
|
||
| const std::string DBCONN_NEW_CONNECTION_FAILED = "FAILED to Create new Connection"; | ||
| const std::string DBCONN_CONNECT_To_DB_FAILED = "FAILED to Connect to DB"; | ||
| const std::string DBQUERY_FAILED = "DB Query Failed"; | ||
|
|
||
| const std::string DBTABLE_REFERENCE_COLUMN_NAME = "name"; | ||
| const std::string DBTABLE_REFERENCE_COLUMN_OFFSET = "tiledb_column_offset"; | ||
| const std::string DBTABLE_REFERENCE_COLUMN_LENGTH = "length"; | ||
|
|
||
| const std::string DBTABLE_CALLSET_COLUMN_NAME = "name"; | ||
| const std::string DBTABLE_CALLSET_COLUMN_ID = "id"; | ||
|
|
||
| const std::string DBTABLE_FIELD_COLUMN_ID = "id"; | ||
| const std::string DBTABLE_FIELD_COLUMN_NAME = "field"; | ||
| const std::string DBTABLE_FIELD_COLUMN_FSID = "field_set_id"; | ||
| const std::string DBTABLE_FIELD_COLUMN_TYPE = "type"; | ||
| const std::string DBTABLE_FIELD_COLUMN_FILTER = "is_filter"; | ||
| const std::string DBTABLE_FIELD_COLUMN_FORMAT = "is_format"; | ||
| const std::string DBTABLE_FIELD_COLUMN_INFO = "is_info"; | ||
| const std::string DBTABLE_FIELD_COLUMN_LENTYPE = "length_type"; | ||
| const std::string DBTABLE_FIELD_COLUMN_LENVAL = "length_intval"; | ||
| const std::string DBTABLE_FIELD_COLUMN_COMBOP = "vcf_field_combine_operation"; | ||
|
|
||
| const std::string COMBINE_OPERATION_ERROR_PREFIX = ("VCF field combined operation 'concatenate' can only be used with fields whose length descriptors are 'VAR'; field "); | ||
| const std::string COMBINE_OPERATION_ERROR_SUFFIX = (" does not have 'VAR' as its length descriptor"); | ||
|
|
||
| enum { | ||
| GENOMICSDB_VID_MAPPER_SUCCESS = 0x0, | ||
| GENOMICSDB_VID_MAPPER_FAILURE = 0x1 | ||
| }; | ||
|
|
||
| /** | ||
| * This class encapsulates parameters needed to establish a DB connection and | ||
| * also identify the workspace and db_array. | ||
| */ | ||
| class SQLVidMapperRequest { | ||
| public: | ||
| std::string host_name; | ||
| std::string user_name; | ||
| std::string pass_word; | ||
| std::string db_name; | ||
| std::string work_space; | ||
| std::string array_name; | ||
| }; | ||
|
|
||
| /** | ||
| * This class will be used to load VID Mapper information from DB. In future it | ||
| * may also be used to modify DB info. | ||
| */ | ||
| class SQLBasedVidMapper : public VidMapper { | ||
| public: | ||
| SQLBasedVidMapper(const SQLVidMapperRequest&); | ||
|
|
||
| /* following two declarations disable copy semantics since not needed */ | ||
| SQLBasedVidMapper(const SQLBasedVidMapper&) = delete; | ||
|
|
||
| void operator=(const SQLBasedVidMapper&) = delete; | ||
|
|
||
| /* following two declarations disable move semantics since not needed */ | ||
| SQLBasedVidMapper(SQLBasedVidMapper&&) = delete; | ||
|
|
||
| SQLBasedVidMapper&& operator=(SQLBasedVidMapper&&) = delete; | ||
|
|
||
| /* public method to load all mapping data from DB */ | ||
| int load_mapping_data_from_db(); | ||
|
|
||
| /* following three methods return contig mappings */ | ||
| std::vector<ContigInfo>& get_contigs() { return(m_contig_idx_to_info); } | ||
|
|
||
| std::vector<std::pair<int64_t, int>>& get_contig_begin_offsets() { | ||
| return(m_contig_begin_2_idx); | ||
| } | ||
|
|
||
| std::vector<std::pair<int64_t, int>>& get_contig_end_offsets() { | ||
| return(m_contig_end_2_idx); | ||
| } | ||
|
|
||
| /* following two methods return callset mappings */ | ||
| std::vector<CallSetInfo>& get_callsets() { return(m_row_idx_to_info); } | ||
|
|
||
| std::unordered_map<std::string, int64_t>& get_callset_name_to_idx_map() { | ||
| return(m_callset_name_to_row_idx); | ||
| } | ||
|
|
||
| /* following two methods return field mappings */ | ||
| std::vector<FieldInfo>& get_fields() { return(m_field_idx_to_info); } | ||
|
|
||
| std::unordered_map<std::string, int>& get_field_name_to_idx_map() { | ||
| return(m_field_name_to_idx); | ||
| } | ||
|
|
||
| ~SQLBasedVidMapper(); | ||
| protected: | ||
| dbi_conn m_conn; | ||
| dbi_inst m_instance; | ||
| std::string m_work_space; | ||
| std::string m_array_name; | ||
|
|
||
| /* method to retrieve contig info from DB and load into VID mapper */ | ||
| int load_contig_info(); | ||
|
|
||
| /* method to retrieve callset info from DB and load into VID mapper */ | ||
| int load_callset_info(); | ||
|
|
||
| /* method to retrieve field info from DB and load into VID mapper */ | ||
| int load_field_info(); | ||
| }; | ||
|
|
||
| class SQLBasedVidMapperException : public std::exception { | ||
| public: | ||
| /** | ||
| * Default constructor | ||
| */ | ||
| SQLBasedVidMapperException(const std::string m=""); | ||
|
|
||
| /* | ||
| * Destructor: must be called before end of scope of a | ||
| * VidMapper exception object | ||
| */ | ||
| ~SQLBasedVidMapperException(); | ||
|
|
||
| /* | ||
| * ACCESSORS | ||
| */ | ||
|
|
||
| /** | ||
| * Returns the exception message. | ||
| */ | ||
| const char* what() const noexcept { return msg_.c_str(); } | ||
|
|
||
| private: | ||
| std::string msg_; | ||
| }; | ||
|
|
||
| #endif // GENOMICSDB_VID_MAPPER_SQL_H | ||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the libdbi dependence be optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is optional. If libdbi is not installed in an environment, the dependent files won't be compiled.
SQLVidMapper in this instance.