Xmipp  v3.23.11-Nereus
program_extension.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: J.M. de la Rosa Trevin (jmdelarosam@cnb.csic.es)
3  *
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #include "program_extension.h"
27 
28 //Needed includes for instantiate programs
29 #include <data/filters.h>
33 #include "volume_from_pdb.h"
34 #include "pdb_nma_deform.h"
35 #include "pdb_sph_deform.h"
38 #include "program_filter.h"
39 #include <data/mask.h>
41 
42 void runSystem(const String &program, const String &arguments, bool useSystem) {
43  if (useSystem) {
44  String cmd = formatString("%s %s", program.c_str(), arguments.c_str());
45  if (system(cmd.c_str())==-1)
46  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
47  } else {
48  runProgram(program, arguments);
49  }
50 }
51 
52 int runProgram(XmippProgram * program, const String &arguments, bool destroy)
53 {
54  if (program == nullptr)
55  REPORT_ERROR(ERR_PARAM_INCORRECT, "Received a NULL as program pointer");
56  program->read(arguments);
57  int retCode = program->tryRun();
58  if (destroy)
59  delete program;
60  return retCode;
61 }
62 
63 int runProgram(const String &programName, const String &arguments)
64 {
65  XmippProgram * program = getProgramByName(programName);
66  return runProgram(program, arguments);
67 }
68 
69 XmippProgram * getProgramByName(const String &programName)
70 {
71  // if (programName == "xmipp_tranform_filter")
72  // return new ProgFilter();
73 
74  if (programName == "xmipp_volume_from_pdb")
75  return new ProgPdbConverter();
76 
77  if (programName == "xmipp_angular_project_library")
78  return new ProgAngularProjectLibrary();
79 
80  if (programName == "xmipp_angular_projection_matching")
81  return new ProgAngularProjectionMatching();
82 
83  if (programName == "xmipp_mask")
84  return new ProgMask();
85 
86  if (programName == "xmipp_angular_discrete_assign")
87  return new ProgAngularDiscreteAssign();
88 
89  if (programName == "xmipp_angular_continuous_assign")
90  return new ProgAngularContinuousAssign();
91 
92  if (programName == "xmipp_pdb_nma_deform")
93  return new ProgPdbNmaDeform();
94 
95  if (programName == "xmipp_pdb_sph_deform")
96  return new ProgPdbSphDeform();
97 
98  if (programName == "xmipp_micrograph_automatic_picking")
100 
101  if (programName == "xmipp_classify_analyze_cluster")
102  return new ProgAnalyzeCluster();
103 
104  if (programName == "xmipp_transform_filter")
105  return new ProgFilter();
106 
107  return nullptr;
108 }
109 
110 
Just to locate unclassified errors.
Definition: xmipp_error.h:192
Parameter incorrect.
Definition: xmipp_error.h:181
virtual void read(int argc, const char **argv, bool reportErrors=true)
int runProgram(XmippProgram *program, const String &arguments, bool destroy)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
virtual int tryRun()
void runSystem(const String &program, const String &arguments, bool useSystem)
std::string String
Definition: xmipp_strings.h:34
String formatString(const char *format,...)
XmippProgram * getProgramByName(const String &programName)