Commit e0094b6a authored by Dr. Carsten Kemena's avatar Dr. Carsten Kemena
Browse files

adding PfamMeta

parent 69ba9294
Pipeline #105243 passed with stages
in 1 minute and 10 seconds
......@@ -24,8 +24,8 @@
*/
#ifndef SRC_INTERPROMATCHREADER
#define SRC_INTERPROMATCHREADER
#ifndef SRC_DOMAIN_INTERPROMATCHREADER
#define SRC_DOMAIN_INTERPROMATCHREADER
#include <boost/filesystem.hpp>
......
......@@ -29,8 +29,8 @@
* \file PfamDomain.hpp
* \brief Header containing the PfamDomain class.
*/
#ifndef SRC_ANNOTATION_PFAMDOMAIN_HPP_
#define SRC_ANNOTATION_PFAMDOMAIN_HPP_
#ifndef SRC_DOMAIN_PFAMDOMAIN_HPP_
#define SRC_DOMAIN_PFAMDOMAIN_HPP_
#include <stddef.h> // for size_t
#include <algorithm> // for move, forward
......
/*
* PfamMeta.hpp
*
* Created on: 04 Nov 2021
* Author: Carsten Kemena
* Email: c.kemena[@]uni-muenster.de
* Copyright: 2021
*
* This file is part of BioSeqDataLib.
*
* BioSeqDataLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BioSeqDataLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BioSeqDataLib. If not, see <http://www.gnu.org/licenses/>.
*/
#include <map>
#include <set>
#include <string>
#include <vector>
#ifndef SRC_DOMAIN_PFAMMETA_HPP_
#define SRC_DOMAIN_PFAMMETA_HPP_
namespace BioSeqDataLib
{
struct PfamMeta
{
std::string id;
std::string name;
std::string clan;
std::string type;
unsigned short modelLength;
std::vector<std::string> goTerms;
PfamMeta()
{}
PfamMeta(const std::string &i,
const std::string &n,
const std::string &c,
const std::string &t,
unsigned short m
) : id(i), name(n), clan(c), type(t), modelLength(m)
{}
friend bool operator < (const PfamMeta& c1, const PfamMeta& c2);
};
bool operator< (const PfamMeta& c1, const PfamMeta& c2)
{
return (c1.id < c2.id);
}
class PfamMetaCollection
{
private:
std::map<std::string, PfamMeta> collection_;
public:
void
addData(PfamMeta &&data)
{
collection_.emplace(data.id, std::move(data));
}
void
addData(PfamMeta &data)
{
collection_.emplace(data.id, data);
}
unsigned short
getModelLength(const std::string &id) const
{
return collection_.at(id).modelLength;
}
std::string
getClan(const std::string &id) const
{
return collection_.at(id).clan;
}
std::string
getType(const std::string &id) const
{
return collection_.at(id).type;
}
};
}
#endif
\ No newline at end of file
......@@ -24,8 +24,8 @@
#ifndef SRC_ANNOTATION_SFDOMAIN_HPP_
#define SRC_ANNOTATION_SFDOMAIN_HPP_
#ifndef SRC_DOMAIN_SFDOMAIN_HPP_
#define SRC_DOMAIN_SFDOMAIN_HPP_
#include <stddef.h> // for size_t
#include <string> // for string, allocator
......
#ifndef INTERPROXMLREADER_TEST_HPP_
#define INTERPROXMLREADER_TEST_HPP_
#include <boost/test/unit_test.hpp>
#include <iostream>
#include "../../src/domain/PfamMeta.hpp"
BOOST_AUTO_TEST_SUITE(PfamMeta_Test)
BOOST_AUTO_TEST_CASE( Basic_Test )
{
BioSeqDataLib::PfamMeta a("PF00001", "testDomain", "CL0123", "Family", 100);
BOOST_CHECK_EQUAL(a.id, "PF00001");
BOOST_CHECK_EQUAL(a.name, "testDomain");
BOOST_CHECK_EQUAL(a.clan, "CL0123");
BOOST_CHECK_EQUAL(a.type, "Family");
BOOST_CHECK_EQUAL(a.modelLength, 100);
BioSeqDataLib::PfamMeta b;
b.id = "PF00002";
BOOST_CHECK(a < b);
}
BOOST_AUTO_TEST_CASE( Collection_Basic_Test )
{
BioSeqDataLib::PfamMetaCollection c;
BioSeqDataLib::PfamMeta a("PF00002", "testDomain2", "CL0123", "Family", 100);
BioSeqDataLib::PfamMeta b("PF00003", "testDomain3", "", "Motiv", 101);
BioSeqDataLib::PfamMeta d("PF00001", "testDomain1", "CL0123", "Family", 100);
c.addData(std::move(a));
c.addData(std::move(b));
c.addData(std::move(d));
BOOST_CHECK_EQUAL(c.getClan("PF00001"), "CL0123");
BOOST_CHECK_EQUAL(c.getModelLength("PF00002"), 100);
BOOST_CHECK_EQUAL(c.getType("PF00003"), "Motiv" );
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* DASSETINPUTSTRATEGIES_TEST_HPP_ */
\ No newline at end of file
......@@ -33,6 +33,7 @@
#include "DASetWriter_Test.hpp"
#include "DomainTest.hpp"
#include "PfamMeta_Test.hpp"
#include "DomainArrangementTest.hpp"
#include "DomainArrangementSetTest.hpp"
#include "InterProXMLReader_Test.hpp"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment