Skip to content

Commit

Permalink
Add test_scripts/pdb2mega.bash, prepping for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
rcedgar committed Aug 19, 2024
1 parent 6dd83f7 commit b8897f4
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 70 deletions.
15 changes: 6 additions & 9 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
########################################################
######################################################
# Makefile is generated by ./build_linux.py
# Don't edit the Makefile -- update the generator script
########################################################
# Don't edit the Makefile -- update the python script
######################################################

BINDIR := ../bin
OBJDIR := o
BINPATH := $(BINDIR)/reseek

CC = gcc
CFLAGS := $(CFLAGS) -O3 -ffast-math -march=native
CFLAGS := $(CFLAGS) -ffast-math -march=native --std=c++17 -O3 -DNDEBUG -fopenmp

CXX = g++
CXXFLAGS := $(CFLAGS) -DNDEBUG -pthread -O3 -ffast-math -march=native --std=c++17
CXXFLAGS := $(CFLAGS) -ffast-math -march=native --std=c++17 -O3 -DNDEBUG -fopenmp

UNAME_S := $(shell uname -s)
LDFLAGS := $(LDFLAGS) -pthread -lpthread
LDFLAGS := $(LDFLAGS) -ffast-math -march=native -O3 -fopenmp
ifeq ($(UNAME_S),Linux)
LDFLAGS += -static
endif
Expand Down Expand Up @@ -257,6 +257,3 @@ $(OBJDIR)/%.o : %.c $(HDRS)

$(OBJDIR)/%.o : %.cpp $(HDRS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<

clean:
rm -rf $(OBJDIR)/ $(BINPATH)
1 change: 1 addition & 0 deletions src/build_linux.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./build_linux.py --openmp --std 17
145 changes: 86 additions & 59 deletions src/build_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@

import os
import sys
import argparse

DebugBuild = len(sys.argv) > 1 and sys.argv[1] == "d"
Usage = \
(
"Convert Visual Studio .vcxproj file in current directory to Makefile and run make."
)

rc = os.system('test -z $(git status --porcelain) 2> /dev/null')
if rc != 0:
sys.stderr.write("\n\nWARNING -- Uncommited changes\n\n")
## sys.exit(1)
AP = argparse.ArgumentParser(description = Usage)

rc = os.system(r'echo \"$(git log --oneline | head -n1 | cut "-d " -f1)\" | tee gitver.txt')
if rc != 0:
sys.stderr.write("\n\nERROR -- failed to generate gitver.txt\n\n")
sys.exit(1)
# Value opts
AP.add_argument("--std", required=False, help="Don't strip symbols (default if --debug or --symbols)")

OBJDIR = "o"
BINDIR = "../bin"
# Flag opts
AP.add_argument("--debug", required=False, action='store_true', help="Debug build")
AP.add_argument("--openmp", required=False, action='store_true', help="Requires OMP")
AP.add_argument("--pthread", required=False, action='store_true', help="Requires pthread")
AP.add_argument("--lrt", required=False, action='store_true', help="Requires lrt")
AP.add_argument("--symbols", required=False, action='store_true', help="Debug symbols (default if --debug)")
AP.add_argument("--nostrip", required=False, action='store_true', help="Don't strip symbols (default if --debug or --symbols)")

LRT = False
DEBUG = False
SVNVER = False
Args = AP.parse_args()
debug = Args.debug
std = Args.std
nostrip = debug or Args.symbols
symbols = debug or Args.symbols

ProjFileName = None
HdrNames = []
Expand All @@ -30,13 +36,62 @@
elif FileName.endswith(".h"):
HdrNames.append(FileName)
if ProjFileName is None:
print("Project file not found in current directory", file=sys.stderr)
sys.stderr.write("\nProject file not found in current directory\n")
sys.exit(1)

binary = ProjFileName.replace(".vcxproj", "")
sys.stderr.write("binary=" + binary + "\n")

compiler_opts = " -ffast-math -march=native"
linker_opts = " -ffast-math -march=native"

if std:
assert std == "11" or std == "17"
compiler_opts += " --std=c++" + std

if debug:
compiler_opts += " -O0 -DDEBUG"
linker_opts += " -O0"
else:
compiler_opts += " -O3 -DNDEBUG"
linker_opts += " -O3"

if symbols:
compiler_opts += " -g3"
linker_opts += " -g3"

if Args.openmp:
compiler_opts += " -fopenmp"
linker_opts += " -fopenmp"

if Args.pthread:
compiler_opts += " -pthread"
linker_opts += " -lpthread"

rc = os.system('test -z $(git status --porcelain) 2> /dev/null')
if rc != 0:
sys.stderr.write("\n\nWarning -- Uncommited changes\n\n")

rc = os.system(r'echo \"$(git log --oneline | head -n1 | cut "-d " -f1)\" | tee gitver.txt')
if rc != 0:
sys.stderr.write("\n\nERROR -- failed to generate gitver.txt\n\n")
sys.exit(1)
sys.stderr.write("gitver.txt done.\n")

rc = os.system(r'rm -rf o/ ../bin/%s*' % binary)
if rc != 0:
sys.stderr.write("\n\nERROR -- failed to clean\n\n")
sys.exit(1)
sys.stderr.write("clean done.\n")

OBJDIR = "o"
BINDIR = "../bin"

Fields = ProjFileName.split("/")
n = len(Fields)
Name = Fields[n-1]
Fields = Name.split(".")
progname = Fields[0]
binary = Fields[0]

CXXNames = []
CNames = []
Expand All @@ -58,60 +113,37 @@
elif FileName.endswith(".c"):
FileName = FileName.replace(".c", "")
CNames.append(FileName)
# <ProjectName>usearch</ProjectName>
elif Line.startswith("<ProjectName"):
Line = Line.replace("<ProjectName>", "")
Line = Line.replace("</ProjectName>", "")
progname = Line

assert len(CXXNames) > 0 or len(CNames) > 0

Makefile = "Makefile"
if DebugBuild:
Makefile = "Makefiled"
with open(Makefile, "w") as f:
with open("Makefile", "w") as f:
def Out(s):
print(s, file=f)

if DebugBuild:
BINPATH = "$(BINDIR)/%s" % (progname) + "d"
else:
BINPATH = "$(BINDIR)/%s" % (progname)
BINPATH = "$(BINDIR)/%s" % (binary)

Out("########################################################")
Out("# Makefile is generated by %s" % sys.argv[0])
Out("# Don't edit the Makefile -- update the generator script")
Out("########################################################")
Out("######################################################")
Out("# Makefile is generated by " + sys.argv[0])
Out("# Don't edit the Makefile -- update the python script")
Out("######################################################")
Out("")
Out("BINDIR := %s" % BINDIR)
Out("OBJDIR := %s" % OBJDIR)
Out("BINPATH := %s" % BINPATH)

# Out("")
# Out("CPPFLAGS := $(CPPFLAGS) -DNDEBUG -pthread")

if CNames:
Out("")
Out("CC = gcc")
if DebugBuild:
Out("CFLAGS := $(CFLAGS) -ffast-math -march=native")
else:
Out("CFLAGS := $(CFLAGS) -O3 -ffast-math -march=native")
Out("CFLAGS := $(CFLAGS) " + compiler_opts)

if CXXNames:
Out("")
Out("CXX = g++")
if DebugBuild:
Out("CXXFLAGS := $(CFLAGS) -DDEBUG -pthread -march=native --std=c++17")
else:
Out("CXXFLAGS := $(CFLAGS) -DNDEBUG -pthread -O3 -ffast-math -march=native --std=c++17")
Out("CXXFLAGS := $(CFLAGS) " + compiler_opts)

Out("")
Out("UNAME_S := $(shell uname -s)")
if DebugBuild:
Out("LDFLAGS := $(LDFLAGS) -O3 -pthread -lpthread")
else:
Out("LDFLAGS := $(LDFLAGS) -pthread -lpthread")
Out("LDFLAGS := $(LDFLAGS) " + linker_opts)
Out("ifeq ($(UNAME_S),Linux)")
Out(" LDFLAGS += -static")
Out("endif")
Expand Down Expand Up @@ -140,11 +172,11 @@ def Out(s):
else:
Cmd = "\t%(CC) $(LDFLAGS) $(OBJS) -o $(BINPATH)"

if LRT:
if Args.lrt:
Cmd += " -lrt"
Out(Cmd)

if not DebugBuild:
if not nostrip:
Out(" strip $(BINPATH)")

Out("")
Expand All @@ -165,17 +197,12 @@ def Out(s):
Out("$(OBJDIR)/%.o : %.cpp $(HDRS)")
Out(" $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<")

Out("")
Out("clean:")
Out(" rm -rf $(OBJDIR)/ $(BINPATH)")

if DebugBuild:
rc = os.system("rm -f o/myutils.o ../bin/%sd" % progname)
else:
rc = os.system("rm -f o/myutils.o ../bin/%s" % progname)
sys.stderr.write("Makefile done.\n")

rc = os.system("make -f %s > make.stdout 2> make.stderr" % Makefile)
rc = os.system("make 2> make.stderr | tee make.stdout")
if rc != 0:
os.system("tail make.stderr")
sys.stderr.write("\n\nERROR -- make failed, see make.stderr\n\n")
sys.exit(1)
sys.stderr.write("make done.\n")
os.system("ls -lh ../bin/" + binary + "\n")
10 changes: 10 additions & 0 deletions src/daliscorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ void DALIScorer::LoadChains(const string &FN)
m_SeqToChainIdx[ptrChain->m_Seq] = Idx;
}
Progress("Reading chains done (%u)\n", SIZE(m_Chains));
{//@@
for (map<string, uint>::const_iterator iter = m_SeqToChainIdx.begin();
iter != m_SeqToChainIdx.end(); ++iter)
{
Log("[%u] %s\n", iter->second, iter->first);
}

}//@@
}

void DALIScorer::SetCore()
Expand Down Expand Up @@ -129,6 +137,8 @@ bool DALIScorer::SetSeqIdxToChainIdx(bool MissingSeqOk)
const string &Label = string(m_MSA->GetLabel(SeqIdx));
string Seq;
m_MSA->GetSeq_StripGaps(SeqIdx, Seq, true);
Log(">%s\n", Label.c_str());//@@
Log("%s\n", Seq.c_str());//@@
map<string, uint>::const_iterator iter = m_SeqToChainIdx.find(Seq);
if (iter == m_SeqToChainIdx.end())
{
Expand Down
2 changes: 1 addition & 1 deletion src/prettyaln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void PrettyAln(FILE *f, const PDBChain &A, const PDBChain &B,
if (ColHi == ColCount)
break;
asserta(ColHi < ColCount);
ColLo = ColHi + 1;
ColLo = ColHi;
}
double PctId = GetPct(Ids, ColCount);
double PctGaps = GetPct(Gaps, ColCount);
Expand Down
3 changes: 3 additions & 0 deletions src/usage.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const char *usage_txt[] =
" -bca FILENAME # .bca format, binary .cal, recommended for DBs\n"
" -fasta FILENAME # FASTA format\n"
"\n"
"Create input for Muscle-3D multiple structure alignment:\n"
" reseek -pdb2mega STRUCTS -output structs.mega\n"
"\n"
"STRUCTS argument is one of:\n"
" NAME.cif or NAME.mmcif # PDBx/mmCIF file\n"
" NAME.pdb # Legacy format PDB file\n"
Expand Down
4 changes: 3 additions & 1 deletion test_scripts/_run_tests.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash -e

cd ../src
rm -rf o/ ../bin/reseek*
chmod +x ./build_linux.py
python3 ./build_linux.py
cd ../test_scripts
Expand All @@ -23,13 +24,14 @@ echo STARTED `date` >> $log
./columns.bash
./search.bash
./scop40.bash
./pdb2mega.bash

python3 ./check_logs.py >> $log
python3 ./check_convert.py >> $log
python3 ./check_columns.py >> $log
python3 ./check_scop40.py >> $log

./update_success_list.py $ver $date
python3 ./update_success_list.py $ver $date

echo COMPLETED $date >> $log

Expand Down
8 changes: 8 additions & 0 deletions test_scripts/pdb2mega.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e

cd ../test_output

../bin/reseek \
-pdb2mega ../test_structures/4v40.cif \
-output ../test_output/4v40.mega \
-log pdb2mega.log

0 comments on commit b8897f4

Please sign in to comment.