RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
Rbt.h
1/***********************************************************************
2 * The rDock program was developed from 1998 - 2006 by the software team
3 * at RiboTargets (subsequently Vernalis (R&D) Ltd).
4 * In 2006, the software was licensed to the University of York for
5 * maintenance and distribution.
6 * In 2012, Vernalis and the University of York agreed to release the
7 * program as Open Source software.
8 * This version is licensed under GNU-LGPL version 3.0 with support from
9 * the University of Barcelona.
10 * http://rdock.sourceforge.net/
11 ***********************************************************************/
12
13// Miscellaneous non-member functions in rxdock namespace
14#ifndef _RBT_H_
15#define _RBT_H_
16
18
19#include <istream>
20#include <map>
21#include <ostream>
22#include <vector>
23
24namespace rxdock {
25
26// Segment is a named part of an Model (usually an intact molecule)
27// For now, a segment is defined as just an String
28// SegmentMap holds a map of (key=unique segment name, value=number of atoms
29// in segment)
30typedef std::string Segment;
31typedef std::map<Segment, unsigned int> SegmentMap;
32typedef SegmentMap::iterator SegmentMapIter;
33typedef SegmentMap::const_iterator SegmentMapConstIter;
34
36// RESOURCE HANDLING FUNCTIONS
37//
38// GetRoot - returns value of RBT_ROOT env variable
39RBTDLL_EXPORT std::string GetRoot();
40// GetHome - returns value of RBT_HOME env variable
41//(or HOME if RBT_HOME is undefined)
42std::string GetHome();
43// GetProgramName - returns program name
44RBTDLL_EXPORT std::string GetProgramName();
45// GetMetaDataPrefix - returns meta data prefix
46RBTDLL_EXPORT std::string GetMetaDataPrefix();
47// GetCopyright - returns legalese statement
48RBTDLL_EXPORT std::string GetCopyright();
49// GetProgramVersion - returns current library version
50RBTDLL_EXPORT std::string GetProgramVersion();
51// GetProduct - returns library product name
52RBTDLL_EXPORT std::string GetProduct();
53// GetTime - returns current time and date as an String
54std::string GetTime();
55// GetCurrentWorkingDirectory - returns current working directory
56RBTDLL_EXPORT std::string GetCurrentWorkingDirectory();
57//
59
61// FILE/DIRECTORY HANDLING FUNCTIONS
62//
63// GetDirName
64// Returns the full path to a subdirectory in the rDock directory structure
65//
66// For example, if RBT_ROOT environment variable is ~dave/ribodev/molmod/ribodev
67// then GetDirName("data") would return ~dave/ribodev/molmod/ribodev/data/
68//
69// If RBT_ROOT is not set, then GetDirName returns ./ irrespective of the
70// subdirectory asked for. Thus the fall-back position is that parameter files
71// are read from the current directory if RBT_ROOT is not defined.
72std::string GetDirName(const std::string &strSubdir = "");
73
74// GetDataFileName
75// As GetDirName but returns the full path to a file in the rDock directory
76// structure
77RBTDLL_EXPORT std::string GetDataFileName(const std::string &strSubdir,
78 const std::string &strFile);
79
80// GetFileType
81// Returns the string following the last "." in the file name.
82// e.g. GetFileType("receptor.psf") would return "psf"
83std::string GetFileType(const std::string &strFile);
84
85// GetDirList
86// Returns a list of files in a directory (strDir) whose names begin with
87// strFilePrefix (optional) and whose type is strFileType (optional, as returned
88// by GetFileType)
89std::vector<std::string> GetDirList(const std::string &strDir,
90 const std::string &strFilePrefix = "",
91 const std::string &strFileType = "");
92//
94
96// CONVERSION ROUTINES
97//
98// Converts (comma)-delimited string of segment names to segment map
99RBTDLL_EXPORT SegmentMap ConvertStringToSegmentMap(
100 const std::string &strSegments, const std::string &strDelimiter = ",");
101// Converts segment map to (comma)-delimited string of segment names
102std::string ConvertSegmentMapToString(const SegmentMap &segmentMap,
103 const std::string &strDelimiter = ",");
104
105// Returns a segment map containing the members of map1 which are not in map2
106// I know, should really be a template so as to be more universal...one day
107// maybe. Or maybe there is already an STL algorithm for doing this.
108SegmentMap SegmentDiffMap(const SegmentMap &map1, const SegmentMap &map2);
109
110// DM 30 Mar 1999
111// Converts (comma)-delimited string to string list (similar to
112// ConvertStringToSegmentMap, but returns list not map)
113RBTDLL_EXPORT std::vector<std::string>
114ConvertDelimitedStringToList(const std::string &strValues,
115 const std::string &strDelimiter = ",");
116// Converts string list to (comma)-delimited string (inverse of above)
117std::string
118ConvertListToDelimitedString(const std::vector<std::string> &listOfValues,
119 const std::string &strDelimiter = ",");
120
121// Detect terminal width and wrap text to that width
122std::string WrapTextToTerminalWidth(const std::string &text);
123
124//
126
128// I/O ROUTINES
129//
130// PrintStdHeader
131// Print a standard header to an output stream (for log files etc)
132// Contains copyright info, library version, date, time etc
133// DM 19 Feb 1999 - include executable information
134RBTDLL_EXPORT std::ostream &
135PrintStdHeader(std::ostream &s, const std::string &strExecutable = "");
136
137RBTDLL_EXPORT std::ostream &
138PrintBibliographyItem(std::ostream &s, const std::string &publicationKey = "");
139
140// Helper functions to read/write chars from iostreams
141// Throws error if stream state is not Good() before and after the read/write
142// It appears the STL std::ios_base exception throwing is not yet implemented
143// at least on RedHat 6.1, so this is a temporary workaround (yeah right)
144//
145// DM 25 Sep 2000 - with MIPSPro CC compiler, streamsize is not defined,
146// at least with the iostreams library we are using, so typedef it here
147// it is not in gcc 3.2.1 either SJ
148//#ifdef __sgi
149typedef int streamsize;
150//#endif
151
152RBTDLL_EXPORT void WriteWithThrow(std::ostream &ostr, const char *p,
153 streamsize n);
154RBTDLL_EXPORT void ReadWithThrow(std::istream &istr, char *p, streamsize n);
155
156} // namespace rxdock
157
158#endif //_RBT_H_