Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arg fix #2504

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Arg fix #2504

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion data/bondtyp.txt
Expand Up @@ -97,7 +97,8 @@

# if three N are present in R-N-guanidine-ish, prefer double bond to the
# non-terminal N (i.e. D2 if present)
[#6D3^2;!R]([#7D2;!R])([#7D1;!R])~[#7D1;!R] 0 1 2 0 2 1 0 3 1
[#6D3^2;!R]([#7D2;!R])([#7D1;!R])~[#7D1;!R;+0] 0 1 2 0 2 1 0 3 1
[#6D3^2;!R]([#7D2;!R])([#7D1;!R])~[#7D1;!R;+] 0 1 1 0 2 1 0 3 2
# guanidinium and amidine -C(=NH)NH2 without hydrogens
[#6D3^2;!R]([#7D1H0;!R])([#7;!R])* 0 1 2 0 2 1 0 3 1
# and also with hydrogens
Expand Down
4 changes: 2 additions & 2 deletions data/resdata.txt
Expand Up @@ -52,8 +52,8 @@ BOND CB CG 1
BOND CG CD 1
BOND CD NE 1
BOND NE CZ 1
BOND CZ NH2 2
BOND CZ NH1 1
BOND CZ NH2 1
BOND CZ NH1 2
BOND N H 1
BOND HN N 1
BOND NH1 1HH1 1
Expand Down
26 changes: 23 additions & 3 deletions src/data.cpp
Expand Up @@ -21,6 +21,7 @@ GNU General Public License for more details.
#pragma warning (disable : 4786)
#endif
#include <cstdlib>
#include <algorithm>
#include <openbabel/babelconfig.h>
#include <openbabel/data.h>
#include <openbabel/data_utilities.h>
Expand Down Expand Up @@ -614,14 +615,30 @@ namespace OpenBabel
return(false);
}

static std::string trim(const std::string &s)
{
auto start = s.begin();
while (start != s.end() && std::isspace(*start)) {
start++;
}

auto end = s.end();
do {
end--;
} while (std::distance(start, end) > 0 && std::isspace(*end));

return std::string(start, end + 1);
}

int OBResidueData::LookupBO(const string &s)
{
if (_resnum == -1)
return(0);

string strim = trim(s);
unsigned int i;
for (i = 0;i < _resbonds[_resnum].size();++i)
if (_resbonds[_resnum][i].first == s)
if (_resbonds[_resnum][i].first == strim)
return(_resbonds[_resnum][i].second);

return(0);
Expand All @@ -633,12 +650,15 @@ namespace OpenBabel
return(0);
string s;

s = (s1 < s2) ? s1 + " " + s2 : s2 + " " + s1;
string s1strip = trim(s1);
string s2strip = trim(s2);

s = (s1strip < s2strip) ? s1strip + " " + s2strip : s2strip + " " + s1strip;
unsigned int i;
for (i = 0;i < _resbonds[_resnum].size();++i)
if (_resbonds[_resnum][i].first == s)
if (_resbonds[_resnum][i].first == s) {
return(_resbonds[_resnum][i].second);
}

return(0);
}
Expand Down
2 changes: 1 addition & 1 deletion test/files/gzip.in
Expand Up @@ -6,7 +6,7 @@ CC(Cn1cnc2c1c(=O)n(C)c(=O)n2C)O
CN(CCc1c[nH]c2c1c(O)ccc2)C
COc1c2oc(=O)ccc2c(c2c1occ2)CC(C(O)(C)C)O
#1ubq.pdb.gz
CC(C[C@@H](C(=O)N[C@H](C(=O)NCC(=O)NCC(=O)[O-])CCC/N=C(\[NH3+])/N)NC(=O)[C@@H](NC(=O)[C@@H](NC(=O)[C@H](C(C)C)NC(=O)[C@H](CC(C)C)N)CC(C)C)CCC/N=C(\[NH3+])/N)C.[NH3+]CCCC[C@@H](C(=O)N[C@H](C(=O)NCC(=O)N[C@H](C(=O)N1CCC[C@H]1C(=O)N1CCC[C@H]1C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)NCC(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)NCC(=O)N[C@H](C(=O)N[C@H](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])C)Cc4ccccc4)[C@H](CC)C)CC(C)C)CCCNC(=[NH2+])N)CCC(=O)N)CCC(=O)N)CC(=[O-])O)CCC3)CCC2)[C@H](CC)C)CCC(=O)[O-])CCCC[NH3+])CC(=[O-])O)CCC(=O)N)[C@H](CC)C)CCCC[NH3+])C)CCCC[NH3+])C(C)C)CC(=O)N)CCC(=O)[O-])[C@H](CC)C)[C@@H](C)O)CC(=[O-])O)CO)CCC1)CCC(=O)[O-])C(C)C)CCC(=O)[O-])CC(C)C)[C@@H](C)O)[C@H](CC)C)[C@@H](C)O)CCCC[NH3+])[C@@H](C)O)CC(C)C)[C@@H](C)O)CCCC[NH3+])C(C)C)Cc1ccccc1)[C@H](CC)C)CCC(=O)N)CCSC.N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@H](C(=O)NCC(=O)NCC(=O)[O-])CCCNC(=[NH2+])N)CC(C)C)CCCNC(=[NH2+])N)CC(C)C)C(C)C)CC(C)C.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O ../test/files/1ubq.pdb.gz
# tencmpds.sdf.gz
[O-]C(=O)CC(C[N+](C)(C)C)OC(=O)C
OC(=O)CC(C[N+](C)(C)C)OC(=O)C
Expand Down
149 changes: 149 additions & 0 deletions test/testbabel.py
Expand Up @@ -235,6 +235,155 @@ def testPDBQT(self):
output, error = run_exec(pdb, "obabel -ipdb -opdbqt")
self.assertEqual(output.replace("\r", ""), pdbqt.replace("\r", ""))

def testARG(self):
'''Get correct protonation of arginine'''
self.canFindExecutable("obabel")
arg1 = '''ATOM 1213 N ARG B 57 -19.748 -9.497 -12.692 1.00 13.96 B N
ATOM 1214 CA ARG B 57 -20.874 -10.021 -13.461 1.00 14.94 B C
ATOM 1215 C ARG B 57 -20.773 -9.510 -14.886 1.00 15.07 B C
ATOM 1216 O ARG B 57 -20.694 -8.309 -15.108 1.00 15.56 B O
ATOM 1217 CB ARG B 57 -22.204 -9.574 -12.843 1.00 16.31 B C
ATOM 1218 CG ARG B 57 -22.372 -9.987 -11.398 1.00 18.33 B C
ATOM 1219 CD ARG B 57 -23.782 -9.756 -10.880 1.00 21.63 B C
ATOM 1220 NE ARG B 57 -24.302 -8.403 -11.085 1.00 23.91 B N
ATOM 1221 CZ ARG B 57 -24.000 -7.334 -10.350 1.00 25.07 B C
ATOM 1222 NH1 ARG B 57 -23.127 -7.409 -9.347 1.00 26.54 B N1+
ATOM 1223 NH2 ARG B 57 -24.573 -6.169 -10.630 1.00 27.50 B N
'''
arg1sdf = '''
OpenBabel07012217113D

26 25 0 0 1 0 0 0 0 0999 V2000
-19.7480 -9.4970 -12.6920 N 0 0 0 0 0 0 0 0 0 0 0 0
-20.8740 -10.0210 -13.4610 C 0 0 2 0 0 0 0 0 0 0 0 0
-20.7730 -9.5100 -14.8860 C 0 0 0 0 0 0 0 0 0 0 0 0
-20.6940 -8.3090 -15.1080 O 0 0 0 0 0 0 0 0 0 0 0 0
-22.2040 -9.5740 -12.8430 C 0 0 0 0 0 0 0 0 0 0 0 0
-22.3720 -9.9870 -11.3980 C 0 0 0 0 0 0 0 0 0 0 0 0
-23.7820 -9.7560 -10.8800 C 0 0 0 0 0 0 0 0 0 0 0 0
-24.3020 -8.4030 -11.0850 N 0 0 0 0 0 0 0 0 0 0 0 0
-24.0000 -7.3340 -10.3500 C 0 0 0 0 0 0 0 0 0 0 0 0
-23.1270 -7.4090 -9.3470 N 0 3 0 0 0 0 0 0 0 0 0 0
-24.5730 -6.1690 -10.6300 N 0 0 0 0 0 0 0 0 0 0 0 0
-18.8734 -9.8043 -13.1175 H 0 0 0 0 0 0 0 0 0 0 0 0
-19.8001 -9.8432 -11.7340 H 0 0 0 0 0 0 0 0 0 0 0 0
-20.8414 -11.0905 -13.4505 H 0 0 0 0 0 0 0 0 0 0 0 0
-20.7709 -10.1786 -15.6721 H 0 0 0 0 0 0 0 0 0 0 0 0
-23.0021 -10.0032 -13.4120 H 0 0 0 0 0 0 0 0 0 0 0 0
-22.2157 -8.5043 -12.8659 H 0 0 0 0 0 0 0 0 0 0 0 0
-21.6904 -9.4201 -10.7989 H 0 0 0 0 0 0 0 0 0 0 0 0
-22.1744 -11.0369 -11.3378 H 0 0 0 0 0 0 0 0 0 0 0 0
-23.7869 -9.9579 -9.8292 H 0 0 0 0 0 0 0 0 0 0 0 0
-24.4176 -10.4090 -11.4408 H 0 0 0 0 0 0 0 0 0 0 0 0
-24.9301 -8.2717 -11.8317 H 0 0 0 0 0 0 0 0 0 0 0 0
-22.6971 -8.2681 -9.1318 H 0 0 0 0 0 0 0 0 0 0 0 0
-22.9116 -6.6053 -8.8208 H 0 0 0 0 0 0 0 0 0 0 0 0
-25.2196 -6.1036 -11.3695 H 0 0 0 0 0 0 0 0 0 0 0 0
-24.3512 -5.3709 -10.0980 H 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 12 1 0 0 0 0
1 13 1 0 0 0 0
2 3 1 0 0 0 0
2 5 1 0 0 0 0
2 14 1 6 0 0 0
3 4 2 0 0 0 0
3 15 1 0 0 0 0
5 6 1 0 0 0 0
5 16 1 0 0 0 0
5 17 1 0 0 0 0
6 7 1 0 0 0 0
6 18 1 0 0 0 0
6 19 1 0 0 0 0
7 8 1 0 0 0 0
7 20 1 0 0 0 0
7 21 1 0 0 0 0
8 9 1 0 0 0 0
8 22 1 0 0 0 0
9 10 2 0 0 0 0
9 11 1 0 0 0 0
10 23 1 0 0 0 0
10 24 1 0 0 0 0
11 25 1 0 0 0 0
11 26 1 0 0 0 0
M CHG 1 10 1
M END
$$$$
'''
arg0 = '''ATOM 1213 N ARG B 57 -19.748 -9.497 -12.692 1.00 13.96 B N
ATOM 1214 CA ARG B 57 -20.874 -10.021 -13.461 1.00 14.94 B C
ATOM 1215 C ARG B 57 -20.773 -9.510 -14.886 1.00 15.07 B C
ATOM 1216 O ARG B 57 -20.694 -8.309 -15.108 1.00 15.56 B O
ATOM 1217 CB ARG B 57 -22.204 -9.574 -12.843 1.00 16.31 B C
ATOM 1218 CG ARG B 57 -22.372 -9.987 -11.398 1.00 18.33 B C
ATOM 1219 CD ARG B 57 -23.782 -9.756 -10.880 1.00 21.63 B C
ATOM 1220 NE ARG B 57 -24.302 -8.403 -11.085 1.00 23.91 B N
ATOM 1221 CZ ARG B 57 -24.000 -7.334 -10.350 1.00 25.07 B C
ATOM 1222 NH1 ARG B 57 -23.127 -7.409 -9.347 1.00 26.54 B N
ATOM 1223 NH2 ARG B 57 -24.573 -6.169 -10.630 1.00 27.50 B N
'''
arg0sdf = '''
OpenBabel07012217123D

25 24 0 0 1 0 0 0 0 0999 V2000
-19.7480 -9.4970 -12.6920 N 0 0 0 0 0 0 0 0 0 0 0 0
-20.8740 -10.0210 -13.4610 C 0 0 2 0 0 0 0 0 0 0 0 0
-20.7730 -9.5100 -14.8860 C 0 0 0 0 0 0 0 0 0 0 0 0
-20.6940 -8.3090 -15.1080 O 0 0 0 0 0 0 0 0 0 0 0 0
-22.2040 -9.5740 -12.8430 C 0 0 0 0 0 0 0 0 0 0 0 0
-22.3720 -9.9870 -11.3980 C 0 0 0 0 0 0 0 0 0 0 0 0
-23.7820 -9.7560 -10.8800 C 0 0 0 0 0 0 0 0 0 0 0 0
-24.3020 -8.4030 -11.0850 N 0 0 0 0 0 0 0 0 0 0 0 0
-24.0000 -7.3340 -10.3500 C 0 0 0 0 0 0 0 0 0 0 0 0
-23.1270 -7.4090 -9.3470 N 0 0 0 0 0 0 0 0 0 0 0 0
-24.5730 -6.1690 -10.6300 N 0 0 0 0 0 0 0 0 0 0 0 0
-18.8734 -9.8043 -13.1175 H 0 0 0 0 0 0 0 0 0 0 0 0
-19.8001 -9.8432 -11.7340 H 0 0 0 0 0 0 0 0 0 0 0 0
-20.8414 -11.0905 -13.4505 H 0 0 0 0 0 0 0 0 0 0 0 0
-20.7709 -10.1786 -15.6721 H 0 0 0 0 0 0 0 0 0 0 0 0
-23.0021 -10.0032 -13.4120 H 0 0 0 0 0 0 0 0 0 0 0 0
-22.2157 -8.5043 -12.8659 H 0 0 0 0 0 0 0 0 0 0 0 0
-21.6904 -9.4201 -10.7989 H 0 0 0 0 0 0 0 0 0 0 0 0
-22.1744 -11.0369 -11.3378 H 0 0 0 0 0 0 0 0 0 0 0 0
-23.7869 -9.9579 -9.8292 H 0 0 0 0 0 0 0 0 0 0 0 0
-24.4176 -10.4090 -11.4408 H 0 0 0 0 0 0 0 0 0 0 0 0
-22.6971 -8.2681 -9.1318 H 0 0 0 0 0 0 0 0 0 0 0 0
-22.9116 -6.6053 -8.8208 H 0 0 0 0 0 0 0 0 0 0 0 0
-25.2196 -6.1036 -11.3695 H 0 0 0 0 0 0 0 0 0 0 0 0
-24.3512 -5.3709 -10.0980 H 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 12 1 0 0 0 0
1 13 1 0 0 0 0
2 3 1 0 0 0 0
2 5 1 0 0 0 0
2 14 1 6 0 0 0
3 4 2 0 0 0 0
3 15 1 0 0 0 0
5 6 1 0 0 0 0
5 16 1 0 0 0 0
5 17 1 0 0 0 0
6 7 1 0 0 0 0
6 18 1 0 0 0 0
6 19 1 0 0 0 0
7 8 1 0 0 0 0
7 20 1 0 0 0 0
7 21 1 0 0 0 0
8 9 2 0 0 0 0
9 10 1 0 0 0 0
9 11 1 0 0 0 0
10 22 1 0 0 0 0
10 23 1 0 0 0 0
11 24 1 0 0 0 0
11 25 1 0 0 0 0
M END
$$$$
'''
self.maxDiff = None
#skip subtitle
output, error = run_exec(arg1, "obabel -ipdb -osdf -h")
self.assertEqual(output[24:].replace("\r", ""), arg1sdf[24:].replace("\r", ""))
output, error = run_exec(arg0, "obabel -ipdb -osdf -h")
self.assertEqual(output[24:].replace("\r", ""), arg0sdf[24:].replace("\r", ""))

def testMissingPlugins(self):
if sys.platform.startswith("win32"):
return
Expand Down