Embedding auto-generated UML diagrams to LaTeX output - doxygen

Is it possible to embed the UML diagrams generated with UML_LOOK = YES in the LaTeX output?
Edit:
I am using Doxygen 1.9.1. The output of doxygen -x Doxyfile looks like this:
# Difference with default Doxyfile 1.9.1
PROJECT_NAME = ...
JAVADOC_AUTOBRIEF = YES
TOC_INCLUDE_HEADINGS = 0
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
INPUT = ...
FILE_PATTERNS = *.cpp \
*.h
RECURSIVE = YES
EXAMPLE_PATH = .../examples
USE_MDFILE_AS_MAINPAGE = README.md
HTML_FORMULA_FORMAT = svg
MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/
LATEX_CMD_NAME = pdflatex
HAVE_DOT = YES
COLLABORATION_GRAPH = NO
UML_LOOK = YES
TEMPLATE_RELATIONS = YES
DOT_IMAGE_FORMAT = svg
INTERACTIVE_SVG = YES
DOT_TRANSPARENT = YES
For a minimal source file like
class Lol {
void foo(){}
};
class Bar : public Lol {
};
int main(int argc, char *argv[])
{
return 0;
}
The HTML output contains this kind of diagram:
but the LaTeX PDF contains no graphs.
Edit 2
There seems to be a problem with dot?
Executing external command `dot ".../html/classBar__inherit__graph.dot" -Tsvg -o ".../html/classBar__inherit__graph.svg"`
Executing external command `dot ".../latex/classLol__inherit__graph.dot" -Tpdf -o ".../latex/classLol__inherit__graph.pdf"`
Executing external command `dot ".../html/classLol__inherit__graph.dot" -Tsvg -o ".../html/classLol__inherit__graph.svg"`
Executing external command `dot ".../html/graph_legend.dot" -Tsvg -o ".../html/graph_legend.svg"`
Executing external commanerror: Failed to extract bounding box from generated diagram file .../latex/classLol__inherit__graph.pdf
error: Problems running dot: exit code=0, command='dot', arguments='".../latex/classLol__inherit__graph.dot" -Tpdf -o ".../latex/classLol__inherit__graph.pdf"'
error: Failed to extract bounding box from generated diagram file .../latex/classBar__inherit__graph.pdf
error: Problems running dot: exit code=0, command='dot', arguments='".../latex/classBar__inherit__graph.dot" -Tpdf -o ".../latex/classBar__inherit__graph.pdf"'
error: Failed to extract bounding box from generated diagram file .../latex/classBar__inherit__graph.pdf
error: problem writing FIG 0 figure!

A comment does not accept images, but when I run your example with doxygen 1.9.1 I do see the UML diagram in the LaTeX output:
and
I ran the given example with the extra option -d extcmd (so doxygen -d extmd) which also showed me that the uml diagram was created.
Executing external command `dot ".../html/graph_legend.dot" -Tsvg -o ".../html/graph_legend.svg"`
Executing external command `dot ".../html/class_bar__inherit__graph.dot" -Tsvg -o ".../html/class_bar__inherit__graph.svg"`
Executing external command `dot ".../html/class_lol__inherit__graph.dot" -Tsvg -o ".../html/class_lol__inherit__graph.svg"`
Executing external command `dot ".../latex/class_bar__inherit__graph.dot" -Tpdf -o ".../latex/class_bar__inherit__graph.pdf"`
Executing external command `dot ".../html/inherit_graph_0.dot" -Tsvg -o ".../html/inherit_graph_0.svg"`
Executing external command `dot ".../latex/class_lol__inherit__graph.dot" -Tpdf -o ".../latex/class_lol__inherit__graph.pdf"`
Executing external command `dot ".../html/class_lol__inherit__graph.dot" -Tcmapx -o ".../html/class_lol__inherit__graph.map"`
Executing external command `dot ".../html/class_bar__inherit__graph.dot" -Tcmapx -o ".../html/class_bar__inherit__graph.map"`
Executing external command `dot ".../html/inherit_graph_0.dot" -Tcmapx -o ".../html/inherit_graph_0.map"`
So as far as I can see the UML diagrams are created.
Note: the current doxygen version is 1.9.5

Yes, it is possible, but Cairo 1.17.6 changes the way that the PDFs are encoded, and doxygen fails to process the PDFs generated by dot.
See https://github.com/doxygen/doxygen/issues/9319, and albert's comment below (who figured this out, I am just summarizing the answer).

Related

Samtools/hpc/truncated file

I have tried to submit the script below to HPC
#!/bin/bash
#PBS -N bwa_mem_tumor
#PBS -q batch
#PBS -l walltime=02:00:00
#PBS -l nodes=2:ppn=2
#PBS -j oe
sample=x
ref=absolute/path/GRCh38.p13.genome.fa
fwd=absolutepath/forward_read.fq.gz
rev=absolutepath/reverse_read.fq.gz
module load bio/samtools/1.9
bwa mem $ref $fwd $rev > $sample.tumor.sam && samtools view -S $sample.tumor.sam -b > $sample.tumor.bam && samtools sort $sample.tumor.bam > $sample.tumor.sorted.bam
However as an output I can get only the $sample.tumor.sam and log file says that
Lmod has detected the following error: The following module(s) are unknown:
"bio/samtools/1.9"
Please check the spelling or version number. Also try "module spider ..."
It is also possible your cache file is out-of-date; it may help to try:
$ module --ignore-cache load "bio/samtools/1.9"
Also make sure that all modulefiles written in TCL start with the string
#%Module
However when I input modeles avail it shows that bio/samtools/1.9 is on the list.
Also when i use the option module --ignore-cache load "bio/samtools/1.9"
the result is the same
If i try to continue working with the sam file and input manually the command line
samtools view -b RS0107.tumor.sam > RS0107.tumor.bam
it shows
[W::sam_read1] Parse error at line 200943
[main_samview] truncated file.
What's possibly wrong with the samtools module ir we with the script?

Can you get full command line from process ID (including command line arguments, etc)?

This question is in addition to the question asked here: https://unix.stackexchange.com/questions/163145/how-to-get-whole-command-line-from-a-process. On my system, the following command results in a PID (as expected):
CUDA_VISIBLE_DEVICES=4,5 python3 main.py 1> out.txt 2> err.txt &
Now, the methods in the stack exchange link above provide many solutions. However, when trying these solutions, I only receive the following information:
python3 main.py
Is there a way to return the entire command line "CUDA_VISIBLE_DEVICES=4,5 python3 main.py 1> out.txt 2> err.txt &", not just the portion "python3 main.py"?
No.
Assuming you're on a Linux system, you can find the individual bits, but you can't put it together.
Assume also that the process's PID is in $pid
The CUDA_VISIBLE_DEVICES=4,5 variable gets added to the environment of the python command. You can find it in /proc/$pid/environ but you can't tell which of those variables were specified on the command line: the user could have written
export CUDA_VISIBLE_DEVICES=4,5
python3 main.py 1> out.txt 2> err.txt &
The file redirections are available in /proc/$pid/fd:
/proc/$pid/fd/1 is a symbolic link to out.txt
/proc/$pid/fd/2 is a symbolic link to err.txt
I don't know how to tell if a process is running in the background.
Since you're just interested in the environment: with bash
declare -A environ
while IFS='=' read -r -d '' var value; do
environ["$var"]="$value"
done < /proc/$pid/environ
echo "process has CUDA_VISIBLE_DEVICE value ${environ[CUDA_VISIBLE_DEVICE]}"

gcc command line structure arguments

I try to compile a c file with gcc version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1).
I run the compiler in the source file's folder, but I keep getting the 'file not found' error message for the last argument ('bcm2835').
gcc -o gpio -l rt /home/pi/bcm2835-1.15/src/bcm2835.c -l bcm2835
/usr/bin/ld: cannot find -lbcm2835
collect2: error: ld returned 1 exit status
AFAIK, The gcc does not specify the third argument, I have no idea what this 3rd argument is used for and where to find it.
If I omit that argument, I get several error lines, each for one of the internal commands, like:
undefined reference to bcm2835_init
I also wish to know what the rt stands for. I could not find it in the official gcc docs.
Thanks
After -l, there should be no space. So it should be -lrt (not -l rt) and it should be -lbcm2835 (not -l bcm2835).
You need to add a linker search path with -L (uppercase L) right before calling -lbcm2835.
The input file should usually be last (that's the argument ending with main.c). That would be
gcc -o main -lrt -lbcm2835 /home/pi/bcm2835-1.15/main.c
-l links a library to the program. -L sets the library search path such that -l will find the libraries specified.
See this page for details on -l and -L.

Error in Makefile calling sed with comment character

I'm trying to build lstrip, a Lua utility for compressing Lua source code. I'm trying to build for Lua 5.1.3 on OS X v10.10.3.
I have downloaded and extracted the Lua 5.1.3 source code and modified the Makefile for lstrip to point to this directory. However, when I run make, I get this output:
cc -I/usr/local/src/lua-5.1.3/src -I/usr/local/src/lua-5.1.3/src -O2 -Wall -Wextra -O2 -c -o lstrip.o lstrip.c
lstrip.c:33:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char* argv[])
^
1 warning generated.
sed '/void luaX_next/i#include "proxy.c"' /usr/local/src/lua-5.1.3/src/llex.c > llex.c
sed: 1: "/void luaX_next/i#inclu ...": command i expects \ followed by text
make: *** [llex.c] Error 1
This is what the relevant Makefile command looks like:
llex.c:
sed '/void luaX_next/i#include "proxy.c"' $(LUASRC)/$# > $#
I think that this is because the # in the sed command is being treated like an actual comment, but I'm not sure.
How can I fix the Makefile, or manually run the steps, to get lstrip built?
Full copy of the Makefile follows, in case it matters:
# makefile for lstrip
# change these to reflect your Lua installation (Lua 5.1!)
LUA= /usr/local/src/lua-5.1.3
LUAINC= $(LUA)/src
LUALIB= $(LUA)/src
LUASRC= $(LUA)/src
# no need to change anything below here
CFLAGS= $(INCS) $(WARN) -O2 $G
WARN= -O2 -Wall -Wextra
INCS= -I$(LUAINC) -I$(LUASRC)
LIBS= -L$(LUALIB) -llua -lm
MYNAME= lstrip
MYLIB= $(MYNAME)
T= $(MYNAME)
OBJS= $(MYNAME).o llex.o
TEST= test.lua
all: test
test: $T
$T $(TEST)
$T: $(OBJS)
$(CC) -o $# $(OBJS) $(LIBS)
llex.c:
sed '/void luaX_next/i#include "proxy.c"' $(LUASRC)/$# > $#
llex.o: proxy.c
clean:
-rm -f $(OBJS) core core.* a.out $(MYNAME)
# eof
Hand-build solution:
cp /usr/local/src/lua-5.1.3/src/llex.c .
Hand-edit llex.c to add the line #include "proxy.c" before the line starting with void luaX_next (line 446 for me).
Now run make, which will succeed.
You can find the answer in the sed manual, and it is in the Makefile lines
llex.c:
sed '/void luaX_next/i#include "proxy.c"' $(LUASRC)/$# > $#
Some variable expansion takes place here:
$(LUASRC) is expanded to the variable set above -> $(LUA)/src. Recurse as needed.
$# is replaced with the current target (llex.c)
So this recipe says:
In order to obtain the target llex.c (which will be processed later through other recipes), apply a stream editing command to the file $LUASRC/llex.c and write it to llex.c.
The stream editing command is: look for text "void luaX_next", before printing it, insert line "#include "proxy.c"".
Problem is, the command to do this is not "i" but "i\(newline)", which conflicts with a requirement of Makefiles that recipes must be on a single line.
I suspect that in order to fix your Makefile you need to use a different command than sed; awk can fit the bill although it's a bit more complex.
This line works in Mac OS X and in Linux:
sed '/void luaX_next/{h;s/.*/#include "proxy.c"/;p;g;}' $(LUASRC)/$# > $#

Doxygen does not show Namespaces tab in document although show is YES

I am using doxygen for sometime. I previously generated a documentation for my source code with namespaces. It was working OK. But now I created a new project for my new sources and Doxygen does not put Namespaces tab to the documents although SHOW_NAMESPACES is YES and there are lots of namespaces in the source code. The namespace of classes are seen when selected but I dont have the tab.
What could be the problem?
You either need to give the namespaces some documentation or set EXTRACT_ALL to YES.
Example:
$ mkdir test-dir
$ cd test-dir
$ echo 'namespace test {}' > test.hpp
$ doxygen -g # generate default config file
(output)
$ grep -P '^(EXTRACT_ALL|SHOW_NAMESPACES)' Doxyfile # show default settings
EXTRACT_ALL = NO
SHOW_NAMESPACES = YES
$ doxygen # generate docs
(output)
Now open html/index.html, there won't be a namespace tab. This is what you're seeing.
$ sed -i '/^EXTRACT_ALL/s/NO/YES/' Doxyfile # change setting
$ grep -P '^(EXTRACT_ALL|SHOW_NAMESPACES)' Doxyfile # show change
EXTRACT_ALL = YES
SHOW_NAMESPACES = YES
$ doxygen
(output)
Now open html/index.html, there will be a namespace tab.
Tested with doxygen 1.6.3.