Xmipp  v3.23.11-Nereus
Public Member Functions | List of all members
ProgExtractSubset Class Reference

#include <prog_extract_subset_main.h>

Inheritance diagram for ProgExtractSubset:
Inheritance graph
[legend]
Collaboration diagram for ProgExtractSubset:
Collaboration graph
[legend]

Public Member Functions

virtual void readParams () override
 
virtual void defineParams () override
 
virtual void show () const override
 
virtual void run () override
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
virtual void initComments ()
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
virtual void read (int argc, const char **argv, bool reportErrors=true)
 
virtual void read (int argc, char **argv, bool reportErrors=true)
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Additional Inherited Members

- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippProgram
int errorCode
 
ProgramDefprogDef
 Program definition and arguments parser. More...
 
std::map< String, CommentListdefaultComments
 
int argc
 Original command line arguments. More...
 
const char ** argv
 

Detailed Description

Definition at line 33 of file prog_extract_subset_main.h.

Member Function Documentation

◆ defineParams()

void ProgExtractSubset::defineParams ( )
overridevirtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 29 of file prog_extract_subset_main.cpp.

29  {
30  addUsageLine("Extract a subset of particles into a new file. "
31  "By default, only 'Enabled' particles will be kept.");
32 
33  addParamsLine(" -i <md_file> : Input metadata");
34  addParamsLine(" -o <md_file> : Output metadata");
35  addParamsLine(" [--odir <outputDir=\".\">] : Output directory");
36  addParamsLine(" [--keepDisabled] : Ignore 'Enable' flag, i.e. include also disabled particles");
37  addParamsLine(" [--first <n=10>] : Extract first up to n particles");
38  addParamsLine(" [--last <n=10>] : Extract last up to n particles");
39  addParamsLine(" [--range <s=0> <e=10>] : Extract particles within this zero-based range");
40 }
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgExtractSubset::readParams ( )
overridevirtual

Function in which each program will read parameters that it need. If some error occurs the usage will be printed out.

Reimplemented from XmippProgram.

Definition at line 42 of file prog_extract_subset_main.cpp.

42  {
43  m_settings.skipDisabled = ! checkParam("--keepDisabled");
44  MetaData &md = m_settings.md;
45  md.read(getParam("-i"));
46  if (m_settings.skipDisabled) {
47  md.removeDisabled();
48  }
49  size_t n = md.size();
50 
51  if (checkParam(OPT_FIRST)) {
52  m_settings.first = 0;
53  m_settings.count = std::min(n, (size_t)getIntParam(OPT_FIRST));
54  } else if (checkParam(OPT_LAST)) {
55  m_settings.count = std::min(n, (size_t)getIntParam(OPT_LAST));
56  m_settings.first = (0 == m_settings.count) ? 0 : n - m_settings.count;
57  } else if (checkParam(OPT_RANGE)) {
58  size_t reqS = getIntParam(OPT_RANGE, 0);
59  size_t reqE = getIntParam(OPT_RANGE, 1);
60  size_t last = std::min((0 == n ? 0 : n - 1), reqE);
61  m_settings.first = std::min((0 == n ? 0 : n - 1), reqS);
62  m_settings.count = last - m_settings.first + 1;
63  } else {
64  m_settings.first = 0;
65  m_settings.count = n;
66  }
67 
68  prepareOutput();
69 }
void min(Image< double > &op1, const Image< double > &op2)
const char * getParam(const char *param, int arg=0)
virtual size_t size() const =0
virtual void removeDisabled()
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)
int * n
virtual void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true)=0

◆ run()

void ProgExtractSubset::run ( )
overridevirtual

This function will be start running the program. it also should be implemented by derived classes.

Reimplemented from XmippProgram.

Definition at line 99 of file prog_extract_subset_main.cpp.

99  {
100  show();
101  ExtractSubset::createSubset(m_settings);
102 }
virtual void show() const override
static void createSubset(const Settings &s)

◆ show()

void ProgExtractSubset::show ( ) const
overridevirtual

Show parameters

Reimplemented from XmippProgram.

Definition at line 93 of file prog_extract_subset_main.cpp.

93  {
94  if (verbose < 1) return;
95 
96  std::cout << m_settings;
97 }
int verbose
Verbosity level.

The documentation for this class was generated from the following files: