Skip to content

Commit

Permalink
Merge pull request #3 from ncbi/dev
Browse files Browse the repository at this point in the history
Version 1.0.24 
Includes several requested changes and updated tests
  • Loading branch information
evolarjun authored Aug 6, 2024
2 parents ad18e3a + 926d9fe commit 5c9d2df
Show file tree
Hide file tree
Showing 16 changed files with 1,420 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.o
stxtyper
fasta_check
fasta_extract
stx.prot.*
*.got
5 changes: 3 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
warranties of performance, merchantability or fitness for any particular
purpose.

Please cite the author in any work or product based on this material.

Manuscript in preparation. Please cite https://github.com/ncbi/stxtyper in
any work or product based on this material.

40 changes: 21 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ ifneq '$(INSTALL_DIR)' ''
bindir=$(INSTALL_DIR)
endif
bindir ?= $(PREFIX)/bin
ifneq '$(CONDA_DB_DIR)' ''
DBDIR := -D'CONDA_DB_DIR="$(CONDA_DB_DIR)"'
endif
ifneq '$(DEFAULT_DB_DIR)' ''
DBDIR := -D'CONDA_DB_DIR="$(DEFAULT_DB_DIR)"'
endif


# detect system architecture and set appropriate flags
# this is probably not the best way (i.e. M1 Mac would be arm64)
Expand All @@ -74,13 +67,21 @@ endif
# was: -std=gnu++14

CXX=g++
COMPILE.cpp= $(CXX) $(CPPFLAGS) $(SVNREV) $(DBDIR) $(TEST_UPDATE_DB) -c
COMPILE.cpp= $(CXX) $(CPPFLAGS) $(SVNREV) $(DBDIR) -c


.PHONY: all clean install release test

BINARIES= stxtyper fasta_check
BINARIES= stxtyper fasta_check fasta_extract
DATABASE= stx.prot
TEST= test/amrfinder_integration.expected test/cases.expected \
test/amrfinder_integration.fa test/cases.fa \
test/amrfinder_integration2.expected test/synthetics.expected \
test/amrfinder_integration2.fa test/synthetics.fa \
test/basic.expected test/virulence_ecoli.expected \
test/basic.fa test/virulence_ecoli.fa \
test/basic.nuc_out.expected


all: $(BINARIES)

Expand All @@ -90,7 +91,7 @@ all: $(BINARIES)
common.o: common.hpp common.inc

stxtyper.o: common.hpp common.inc
stxtyperOBJS=stxtyper.o common.o
stxtyperOBJS=stxtyper.o common.o tsv.o
stxtyper: $(stxtyperOBJS)
$(CXX) -o $@ $(stxtyperOBJS) -pthread $(DBDIR)

Expand All @@ -99,6 +100,10 @@ fasta_checkOBJS=fasta_check.o common.o
fasta_check: $(fasta_checkOBJS)
$(CXX) -o $@ $(fasta_checkOBJS)

fasta_extract.o: common.hpp common.inc
fasta_extractOBJS=fasta_extract.o common.o
fasta_extract: $(fasta_extractOBJS)
$(CXX) -o $@ $(fasta_extractOBJS)

clean:
rm -f *.o
Expand All @@ -112,23 +117,20 @@ install:
$(INSTALL) $(BINARIES) $(DATABASE) $(DESTDIR)$(bindir)

# stxtyper binaries for github binary release
GITHUB_FILE=stxtyper_binaries_v$(VERSION_STRING)
GITHUB_FILES = $(BINARIES) $(DATABASE)
github_binaries:
GITHUB_FILE=stxtyper_v$(VERSION_STRING)_$(ARCH)_$(OS)
GITHUB_FILES = $(BINARIES) $(DATABASE) version.txt test_stxtyper.sh
binary_dist:
@if [ ! -e version.txt ]; \
then \
echo >&2 "version.txt required to make a distribution file"; \
false; \
fi
# first recompile stxtyper.o to pick up the new version info
rm stxtyper.o stxtyper
make
mkdir $(GITHUB_FILE)
echo $(VERSION_STRING) > $(GITHUB_FILE)/version.txt
cp $(GITHUB_FILES) $(GITHUB_FILE)
mkdir $(GITHUB_FILE)/test
cp $(TEST) $(GITHUB_FILE)/test
if [ -e $(GITHUB_FILE).tar.gz ]; then rm $(GITHUB_FILE).tar.gz; fi
cd $(GITHUB_FILE); tar cvfz ../$(GITHUB_FILE).tar.gz *
# tar cvfz $(GITHUB_FILE).tar.gz $(GITHUB_FILE)/*
tar cvfz $(GITHUB_FILE).tar.gz $(GITHUB_FILE)/*
rm -r $(GITHUB_FILE)/*
rmdir $(GITHUB_FILE)

Expand Down
46 changes: 23 additions & 23 deletions common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ void Xml::TextFile::tagStart (const string &tag)
string tag_ (tag);
replace (tag_, ':', '_');
if (! isIdentifier (tag_, true))
throw runtime_error (FUNC "Bad tag name: " + strQuote (tag));
throw runtime_error (FUNC "Bad textual XML tag name: " + strQuote (tag));

printRaw ("<" + tag + ">");
}
Expand Down Expand Up @@ -3689,14 +3689,11 @@ string Application::key2shortHelp (const string &name) const



string Application::getInstruction (bool coutP) const
string Application::getInstruction (bool screen) const
{
string instr (description);

if (isRedirected (cout))
coutP = false;

instr += "\n\n" + colorize ("USAGE", coutP) + ": " + programName;
instr += "\n\n" + colorize ("USAGE", screen) + ": " + programName;

for (const Positional& p : positionalArgs)
instr += " " + p. str ();
Expand Down Expand Up @@ -3728,10 +3725,10 @@ string Application::getInstruction (bool coutP) const
if (! requiredGroup_prev. empty ())
instr += ")";

instr += "\n" + colorize ("HELP", coutP) + ": " + programName + " " + ifS (gnu, "-") + "-" + helpS;
instr += "\n" + colorize ("HELP", screen) + ": " + programName + " " + ifS (gnu, "-") + "-" + helpS;
if (gnu)
instr += " or " + programName + " -" + helpS [0];
instr += "\n" + colorize ("VERSION", coutP) + ": " + programName + " " + ifS (gnu, "-") + "-" + versionS;
instr += "\n" + colorize ("VERSION", screen) + ": " + programName + " " + ifS (gnu, "-") + "-" + versionS;
if (gnu)
instr += " or " + programName + " -" + versionS [0];

Expand All @@ -3740,42 +3737,43 @@ string Application::getInstruction (bool coutP) const



string Application::getDocumentation () const
string Application::getDocumentation (bool screen) const
{
if (documentationUrl. empty ())
return noString;
return "\n\n" + colorize ("DOCUMENTATION", true) + "\n See " + documentationUrl + " for full documentation";
return "\n\n" + colorize ("DOCUMENTATION", screen) + "\n See " + colorizeUrl (documentationUrl, screen) + " for full documentation";
}



string Application::getUpdates () const
string Application::getUpdates (bool screen) const
{
if (updatesDoc. empty ())
return noString;
return "\n\n" + colorize ("UPDATES", true) + "\n" + updatesDoc;
string s ("\n\n" + colorize ("UPDATES", screen) + "\n" + updatesDoc);
if (! updatesUrl. empty ())
s += ": " + colorizeUrl (updatesUrl, screen);
return s;
}



string Application::getHelp () const
string Application::getHelp (bool screen) const
{
string instr (getInstruction (true));
string instr (getInstruction (screen));

const string par ("\n ");

const bool coutP = ! isRedirected (cout);

if (! positionalArgs. empty ())
{
instr += "\n\n" + colorize ("POSITIONAL PARAMETERS", coutP) /*+ ":"*/;
instr += "\n\n" + colorize ("POSITIONAL PARAMETERS", screen) /*+ ":"*/;
for (const Positional& p : positionalArgs)
instr += "\n" + p. str () + par + p. description;
}

if (! keyArgs. empty ())
{
instr += "\n\n" + colorize ("NAMED PARAMETERS", coutP) /*+ ":"*/;
instr += "\n\n" + colorize ("NAMED PARAMETERS", screen) /*+ ":"*/;
for (const Key& key : keyArgs)
{
instr += "\n" + key. getShortHelp () + par + key. description;
Expand Down Expand Up @@ -3875,7 +3873,8 @@ int Application::run (int argc,

if (name == helpS || (name. empty () && c == helpS [0] && gnu))
{
cout << getHelp () << getDocumentation () << getUpdates () << endl;
const bool screen = ! isRedirected (cout);
cout << getHelp (screen) << getDocumentation (screen) << getUpdates (screen) << endl;
return 0;
}
if (name == versionS || (name. empty () && c == versionS [0] && gnu))
Expand Down Expand Up @@ -3921,7 +3920,8 @@ int Application::run (int argc,

if (programArgs. size () == 1 && (! positionalArgs. empty () || needsArg))
{
cout << getInstruction (true) << getDocumentation () << endl;
const bool screen = ! isRedirected (cout);
cout << getInstruction (screen) << getDocumentation (screen) << endl;
return 1;
}

Expand Down Expand Up @@ -4032,7 +4032,7 @@ int Application::run (int argc,
}
catch (const std::exception &e)
{
errorExit ((e. what () + ifS (errno, string ("\n") + strerror (errno))). c_str ());
errorExit ((ifS (errno, strerror (errno) + string ("\n")) + e. what ()). c_str ());
}


Expand Down Expand Up @@ -4142,9 +4142,9 @@ void ShellApplication::initVar ()



string ShellApplication::getHelp () const
string ShellApplication::getHelp (bool screen) const
{
string help (Application::getHelp ());
string help (Application::getHelp (screen));
if (useTmp)
help += "\n\nTemporary directory used is $TMPDIR or \"/tmp\"";
return help;
Expand Down
Loading

0 comments on commit 5c9d2df

Please sign in to comment.