Skip to content

Commit

Permalink
Merge pull request #144 from fbergmann/set-kisao-name-automatically
Browse files Browse the repository at this point in the history
When the KiSAO ID is set, automatically set the corresponding name.
  • Loading branch information
fbergmann authored Jun 25, 2021
2 parents 148b70b + 9f45eae commit b10164f
Show file tree
Hide file tree
Showing 8 changed files with 1,163 additions and 7 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@
#
###############################################################################

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.12)
project (libsedml)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

SET (CONAN_PATHS ${CMAKE_BINARY_DIR}/../conan_paths.cmake)
if (NOT EXISTS ${CONAN_PATHS})
SET (CONAN_PATHS ${CMAKE_BINARY_DIR}/conan_paths.cmake)
Expand Down Expand Up @@ -445,12 +449,8 @@ endif(WITH_CSHARP)
# or make test
#

# we do use tests, that require 2.8.4
cmake_minimum_required(VERSION 2.8.4)

enable_testing()


# On some Linux (64bit) systems (64bit) the libraries should be installed into lib64 rather
# than lib. It will default to 'lib' but can be overwritten.

Expand Down
548 changes: 548 additions & 0 deletions src/kisao/KISAO.csv

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions src/kisao/transform_kisao.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 21 12:05:03 2021
@author: Lucian
"""

import csv

kcpp = open("../sedml/kisaomap.cpp", "w")
kcpp.write("""
/**
* \\file kisao.cpp
* \\brief KiSAO map
* \\author Lucian Smith
*
* <!--------------------------------------------------------------------------
*
* This file is part of libSEDML. Please visit http://sed-ml.org for more
* information about SED-ML. The latest version of libSEDML can be found on
* github: https://github.com/fbergmann/libSEDML/
*
*
* Copyright (c) 2013-2021, Frank T. Bergmann
* All rights reserved.
*
* 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.
*
* ---------------------------------------------------------------------- -->
*
*/
#include <map>
#include <string>
std::map<int, std::string> g_kisaomap = {
""")

with open('KISAO.csv', newline='') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
if "Class ID" in row:
continue
k_id = int(row[0].split("_")[-1])
k_name = row[1]
kcpp.write(' {' + str(k_id) + ', "' + k_name + '"},\n')
print(k_id, k_name)

kcpp.write("};\n")
kcpp.close()
12 changes: 12 additions & 0 deletions src/sedml/SedAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@
#include <sedml/SedAlgorithm.h>
#include <sbml/xml/XMLInputStream.h>

#include <map>


using namespace std;



LIBSEDML_CPP_NAMESPACE_BEGIN

extern map<int, string> g_kisaomap;



Expand Down Expand Up @@ -150,6 +153,12 @@ int
SedAlgorithm::setKisaoID(const std::string& kisaoID)
{
mKisaoID = kisaoID;
if (!isSetName()) {
int knum = getKisaoIDasInt();
if (g_kisaomap.find(knum) != g_kisaomap.end()) {
setName(g_kisaomap[knum]);
}
}
return LIBSEDML_OPERATION_SUCCESS;
}

Expand Down Expand Up @@ -976,6 +985,9 @@ SedAlgorithm::setKisaoID(int kisaoID)
<< std::setw(7)
<< kisaoID;
mKisaoID = str.str();
if (!isSetName() && g_kisaomap.find(kisaoID) != g_kisaomap.end()) {
setName(g_kisaomap[kisaoID]);
}
return LIBSEDML_OPERATION_SUCCESS;
}

Expand Down
12 changes: 11 additions & 1 deletion src/sedml/SedAlgorithmParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@
#include <sedml/SedAlgorithmParameter.h>
#include <sedml/SedListOfAlgorithmParameters.h>
#include <sbml/xml/XMLInputStream.h>

#include <map>

using namespace std;



LIBSEDML_CPP_NAMESPACE_BEGIN

extern map<int, string> g_kisaomap;



Expand Down Expand Up @@ -194,6 +195,12 @@ int
SedAlgorithmParameter::setKisaoID(const std::string& kisaoID)
{
mKisaoID = kisaoID;
if (!isSetName()) {
int knum = getKisaoIDasInt();
if (g_kisaomap.find(knum) != g_kisaomap.end()) {
setName(g_kisaomap[knum]);
}
}
return LIBSEDML_OPERATION_SUCCESS;
}

Expand Down Expand Up @@ -1128,6 +1135,9 @@ SedAlgorithmParameter::setKisaoID(int kisaoID)
<< std::setw(7)
<< kisaoID;
mKisaoID = str.str();
if (!isSetName() && g_kisaomap.find(kisaoID) != g_kisaomap.end()) {
setName(g_kisaomap[kisaoID]);
}
return LIBSEDML_OPERATION_SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion src/sedml/SedBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2831,7 +2831,7 @@ void
SedBase::writeAttributes (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream) const
{
string sedmlPrefix = getSedPrefix();
if (!mId.empty() && (mIdAllowedPreV4 || getVersion()>=4) || getLevel()>1)
if (!mId.empty() && (mIdAllowedPreV4 || getVersion()>=4 || getLevel()>1))
{
stream.writeAttribute("id", sedmlPrefix, mId);
}
Expand Down
Loading

0 comments on commit b10164f

Please sign in to comment.