Xmipp  v3.23.11-Nereus
Functions
Some extensions related with Xmipp programs
Collaboration diagram for Some extensions related with Xmipp programs:

Functions

void runSystem (const String &program, const String &arguments, bool useSystem=true)
 
int runProgram (XmippProgram *program, const String &arguments, bool destroy=true)
 
int runProgram (const String &programName, const String &arguments)
 
XmippProgramgetProgramByName (const String &programName)
 

Detailed Description

Program extension routines.

Here you will find some routines which might help you to use programs from other programs. Also providing an accesible interface for binding with Python and/or Java.

Function Documentation

◆ getProgramByName()

XmippProgram* getProgramByName ( const String programName)

This function will create a pointer to XmippProgram taking the program name. If the name is invalid, it will return NULL. This function will be hardcoded since C++ has not easy way to do reflection, so it need to be updated for new programs.

Definition at line 69 of file program_extension.cpp.

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 }

◆ runProgram() [1/2]

int runProgram ( XmippProgram program,
const String arguments,
bool  destroy = true 
)

Run a program passing some arguments. The program will be supplied as a pointer of XmippProgram if destroy is true the program pointer will be freed

Definition at line 52 of file program_extension.cpp.

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 }
Parameter incorrect.
Definition: xmipp_error.h:181
virtual void read(int argc, const char **argv, bool reportErrors=true)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
virtual int tryRun()

◆ runProgram() [2/2]

int runProgram ( const String programName,
const String arguments 
)

Run a program providing the program name. Also the arguments should be supplied in a String.

Definition at line 63 of file program_extension.cpp.

64 {
65  XmippProgram * program = getProgramByName(programName);
66  return runProgram(program, arguments);
67 }
int runProgram(XmippProgram *program, const String &arguments, bool destroy)
XmippProgram * getProgramByName(const String &programName)

◆ runSystem()

void runSystem ( const String program,
const String arguments,
bool  useSystem = true 
)

Run a program either as a system call or as an internal call

Definition at line 42 of file program_extension.cpp.

42  {
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 }
Just to locate unclassified errors.
Definition: xmipp_error.h:192
int runProgram(XmippProgram *program, const String &arguments, bool destroy)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
std::string String
Definition: xmipp_strings.h:34
String formatString(const char *format,...)