Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
3a8fd0eb
Commit
3a8fd0eb
authored
Sep 29, 2020
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove requirement of a full CCP4 installation at runtime
parent
69a2d532
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
92 deletions
+31
-92
include/cif++/Cif++.hpp
+2
-0
src/Compound.cpp
+29
-92
No files found.
include/cif++/Cif++.hpp
View file @
3a8fd0eb
...
@@ -1707,6 +1707,8 @@ class File
...
@@ -1707,6 +1707,8 @@ class File
iterator
begin
()
const
;
iterator
begin
()
const
;
iterator
end
()
const
;
iterator
end
()
const
;
bool
empty
()
const
{
return
mHead
==
nullptr
;
}
const
Validator
&
getValidator
()
const
;
const
Validator
&
getValidator
()
const
;
void
getTagOrder
(
std
::
vector
<
std
::
string
>&
tags
)
const
;
void
getTagOrder
(
std
::
vector
<
std
::
string
>&
tags
)
const
;
...
...
src/Compound.cpp
View file @
3a8fd0eb
...
@@ -1037,6 +1037,8 @@ const std::map<std::string,char> kBaseMap{
...
@@ -1037,6 +1037,8 @@ const std::map<std::string,char> kBaseMap{
class
CompoundFactoryImpl
class
CompoundFactoryImpl
{
{
public
:
public
:
CompoundFactoryImpl
()
{}
CompoundFactoryImpl
(
const
std
::
string
&
file
,
CompoundFactoryImpl
*
next
);
CompoundFactoryImpl
(
const
std
::
string
&
file
,
CompoundFactoryImpl
*
next
);
~
CompoundFactoryImpl
()
~
CompoundFactoryImpl
()
...
@@ -1096,24 +1098,25 @@ class CompoundFactoryImpl
...
@@ -1096,24 +1098,25 @@ class CompoundFactoryImpl
std
::
shared_timed_mutex
mMutex
;
std
::
shared_timed_mutex
mMutex
;
std
::
string
mPath
;
std
::
string
mPath
;
std
::
vector
<
Compound
*>
mCompounds
;
std
::
vector
<
Compound
*>
mCompounds
;
std
::
vector
<
const
Link
*>
mLinks
;
std
::
vector
<
const
Link
*>
mLinks
;
/*unordered_*/
std
::
set
<
std
::
string
>
mKnownPeptides
;
std
::
set
<
std
::
string
>
mKnownPeptides
;
std
::
set
<
std
::
string
>
mKnownBases
;
std
::
set
<
std
::
string
>
mKnownBases
;
std
::
set
<
std
::
string
>
mMissing
;
std
::
set
<
std
::
string
>
mMissing
;
cif
::
File
mFile
;
cif
::
File
mFile
;
cif
::
Category
&
mChemComp
;
CompoundFactoryImpl
*
mNext
=
nullptr
;
CompoundFactoryImpl
*
mNext
;
};
};
// --------------------------------------------------------------------
// --------------------------------------------------------------------
CompoundFactoryImpl
::
CompoundFactoryImpl
(
const
std
::
string
&
file
,
CompoundFactoryImpl
*
next
)
CompoundFactoryImpl
::
CompoundFactoryImpl
(
const
std
::
string
&
file
,
CompoundFactoryImpl
*
next
)
:
mPath
(
file
),
mFile
(
file
),
m
ChemComp
(
mFile
.
firstDatablock
()[
"chem_comp"
]),
m
Next
(
next
)
:
mPath
(
file
),
mFile
(
file
),
mNext
(
next
)
{
{
const
std
::
regex
peptideRx
(
"(?:[lmp]-)?peptide"
,
std
::
regex
::
icase
);
const
std
::
regex
peptideRx
(
"(?:[lmp]-)?peptide"
,
std
::
regex
::
icase
);
for
(
auto
&
chemComp
:
mChemComp
)
auto
&
cat
=
mFile
.
firstDatablock
()[
"chem_comp"
];
for
(
auto
&
chemComp
:
cat
)
{
{
std
::
string
group
,
threeLetterCode
;
std
::
string
group
,
threeLetterCode
;
...
@@ -1126,82 +1129,6 @@ CompoundFactoryImpl::CompoundFactoryImpl(const std::string& file, CompoundFactor
...
@@ -1126,82 +1129,6 @@ CompoundFactoryImpl::CompoundFactoryImpl(const std::string& file, CompoundFactor
}
}
}
}
//struct CompoundFactoryImpl
//{
// CompoundFactoryImpl();
//
// Compound* get(std::string id);
// Compound* create(std::string id);
//
// void pushDictionary(const boost::filesystem::path& dictFile);
//
// // cif::File cf acts as owner of datablock
// cif::Datablock& getDatablock(const std::string& name, cif::File& cf);
//
// deque<cif::File> mDictionaries;
// fs::path mClibdMon;
// std::vector<Compound*> mCompounds;
// boost::shared_mutex mMutex;
//};
//
//CompoundFactoryImpl::CompoundFactoryImpl()
//{
// const char* clibdMon = getenv("CLIBD_MON");
// if (clibdMon == nullptr)
// throw std::runtime_error("Cannot locate peptide list, please source the CCP4 environment");
// mClibdMon = clibdMon;
//}
//
//void CompoundFactoryImpl::pushDictionary(const boost::filesystem::path& dictFile)
//{
// boost::upgrade_lock<boost::shared_mutex> lock(mMutex);
//
// mDictionaries.emplace_back(dictFile);
//}
//
//cif::Datablock& CompoundFactoryImpl::getDatablock(const std::string& name, cif::File& cf)
//{
// cif::Datablock* result = nullptr;
//
// // first check all loaded dictionaries
//
// for (auto d: mDictionaries)
// {
// result = d.get(name);
//
// if (result != nullptr)
// break;
// }
//
// if (not result)
// {
// fs::path resFile = mClibdMon / ba::to_lower_copy(name.substr(0, 1)) / (name + ".cif");
//
// if (not fs::exists(resFile) and (name == "COM" or name == "CON" or "PRN")) // seriously...
// mClibdMon / ba::to_lower_copy(name.substr(0, 1)) / (name + '_' + name + ".cif");
//
// fs::ifstream file(resFile);
// if (file.is_open())
// {
// try
// {
// cf.load(file);
// }
// catch (...)
// {
// throw_with_nested(std::runtime_error("Error while loading " + resFile));
// }
//
// result = cf.get(name);
// }
// }
//
// if (result == nullptr)
// throw std::runtime_error("Failed to load datablock " + name);
//
// return *result;
//}
Compound
*
CompoundFactoryImpl
::
get
(
std
::
string
id
)
Compound
*
CompoundFactoryImpl
::
get
(
std
::
string
id
)
{
{
std
::
shared_lock
lock
(
mMutex
);
std
::
shared_lock
lock
(
mMutex
);
...
@@ -1230,11 +1157,13 @@ Compound* CompoundFactoryImpl::create(std::string id)
...
@@ -1230,11 +1157,13 @@ Compound* CompoundFactoryImpl::create(std::string id)
ba
::
to_upper
(
id
);
ba
::
to_upper
(
id
);
Compound
*
result
=
get
(
id
);
Compound
*
result
=
get
(
id
);
if
(
result
==
nullptr
and
mMissing
.
count
(
id
)
==
0
)
if
(
result
==
nullptr
and
mMissing
.
count
(
id
)
==
0
and
not
mFile
.
empty
()
)
{
{
std
::
unique_lock
lock
(
mMutex
);
std
::
unique_lock
lock
(
mMutex
);
auto
rs
=
mChemComp
.
find
(
cif
::
Key
(
"three_letter_code"
)
==
id
);
auto
&
cat
=
mFile
.
firstDatablock
()[
"chem_comp"
];
auto
rs
=
cat
.
find
(
cif
::
Key
(
"three_letter_code"
)
==
id
);
if
(
not
rs
.
empty
())
if
(
not
rs
.
empty
())
{
{
...
@@ -1334,12 +1263,20 @@ CompoundFactory::CompoundFactory()
...
@@ -1334,12 +1263,20 @@ CompoundFactory::CompoundFactory()
:
mImpl
(
nullptr
)
:
mImpl
(
nullptr
)
{
{
const
char
*
clibdMon
=
getenv
(
"CLIBD_MON"
);
const
char
*
clibdMon
=
getenv
(
"CLIBD_MON"
);
if
(
clibdMon
==
nullptr
)
if
(
clibdMon
!=
nullptr
)
throw
std
::
runtime_error
(
"Cannot locate peptide list, please source the CCP4 environment"
);
{
fs
::
path
db
=
fs
::
path
(
clibdMon
)
/
"list"
/
"mon_lib_list.cif"
;
fs
::
path
db
=
fs
::
path
(
clibdMon
)
/
"list"
/
"mon_lib_list.cif"
;
if
(
fs
::
exists
(
db
))
pushDictionary
(
db
.
string
());
}
pushDictionary
(
db
.
string
());
if
(
mImpl
==
nullptr
)
{
if
(
cif
::
VERBOSE
)
std
::
cerr
<<
"Could not load the mon_lib_list.cif file from CCP4, please make sure you have installed CCP4 and sourced the environment."
<<
std
::
endl
;
mImpl
=
new
CompoundFactoryImpl
();
}
}
}
CompoundFactory
::~
CompoundFactory
()
CompoundFactory
::~
CompoundFactory
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment