Split a variable definition in different lines - makefile

Ok, I suppose this one is silly (and have done it in the past) but I honestly cannot remember how it's done.
I have a variable like :
GCC = gcc
So, far so good...
Now, what if my variable definition is too long and want to split it into different lines, so that it looks nice and manageable?
D_FILES = main console globals components/program components/statement components/statements components/assignment components/loop components/block components/library components/argument components/expression components/expressions components/functionDecl components/ruleDecl components/functionCall components/functionCallSt components/returnSt components/outSt components/inSt

I think you can do something like this
CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \
-DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \
-DDEFBLOCKING=$(DEFBLOCKING)
put backslash at and and new line starting with TAB.

I don't know why you're having trouble using backslashs, but you can do it this way:
D_FILES = main console globals components/program components/statement
D_FILES += components/statements components/assignment components/loop
D_FILES += components/block components/library components/argument
# and so on

Related

snakemake program not running all functions?

configfile: "config.yaml"
DATA = config['DATA_DIR']
BIN = config['BIN']
JASPAR = config['DATA_DIR']
RESULTS = config['RESULTS']
# JASPAR = "{0}/JASPAR2020".format(DATA)
JASPARS, ASSEMBLIES, BATCHES, TFS, BEDS = glob_wildcards(os.path.join(DATA, "{jaspar}", "{assembly}", "TFs", "{batch}", "{tf}", "{bed}.bed"))
rule all:
input:
expand (os.path.join(RESULTS, "{jaspar}", "{assembly}", "LOLA_dbs", "JASPAR2020_LOLA_{batch}.RDS"), jaspar = JASPARS, assembly = ASSEMBLIES, batch = BATCHES)
rule createdb:
input:
files = expand(os.path.join(RESULTS, "{jaspar}", "{assembly}", "data", "{batch}", "{tf}", "regions", "{bed}.bed"), zip, jaspar = JASPARS, assembly = ASSEMBLIES, batch = BATCHES, tf = TFS, bed = BEDS)
output:
os.path.join(RESULTS, "{jaspar}", "{assembly}", "LOLA_dbs", "JASPAR2020_LOLA_{batch}.RDS")
shell:
"""
R --vanilla --slave --silent -f {BIN}/create_lola_db.R \
--args {RESULTS}/{wildcards.jaspar}/{wildcards.assembly}/data/{wildcards.batch} \
{output};
"""
Why my snakemake program is not considering "createdb" rule. It is only considering "all". Can someone please help me with this?
"snakemake only runs the first rule in a Snakefile, by default." - SOURCE
If that first rule's input isn't clearly linked to createdb, it's not going to know to run createdb. Because the only rule it wants to run would have to depend on createdb.
I suspect your problem is the input to your rule createdb shouldn't have expand() used for all the wildcards already handled by rule all, just bed?. See here.
Also other avenues to consider for debugging is investigating what you unpacked glob_wildcards() to and what files is.

Snakemake, how to change output filename when using wildcards

I think I have a simple problem but I don't how to solve it.
My input folder contains files like this:
AAAAA_S1_R1_001.fastq
AAAAA_S1_R2_001.fastq
BBBBB_S2_R1_001.fastq
BBBBB_S2_R2_001.fastq
My snakemake code:
import glob
samples = [os.path.basename(x) for x in sorted(glob.glob("input/*.fastq"))]
name = []
for x in samples:
if "_R1_" in x:
name.append(x.split("_R1_")[0])
NAME = name
rule all:
input:
expand("output/{sp}_mapped.bam", sp=NAME),
rule bwa:
input:
R1 = "input/{sample}_R1_001.fastq",
R2 = "input/{sample}_R2_001.fastq"
output:
mapped = "output/{sample}_mapped.bam"
params:
ref = "refs/AF086833.fa"
run:
shell("bwa mem {params.ref} {input.R1} {input.R2} | samtools sort > {output.mapped}")
The output file names are:
AAAAA_S1_mapped.bam
BBBBB_S2_mapped.bam
I want the output file to be:
AAAAA_mapped.bam
BBBBB_mapped.bam
How can I or change the outputname or rename the files before or after the bwa rule.
Try this:
import pathlib
indir = pathlib.Path("input")
paths = indir.glob("*_S?_R?_001.fastq")
samples = set([x.stem.split("_")[0] for x in paths])
rule all:
input:
expand("output/{sample}_mapped.bam", sample=samples)
def find_fastqs(wildcards):
fastqs = [str(x) for x in indir.glob(f"{wildcards.sample}_*.fastq")]
return sorted(fastqs)
rule bwa:
input:
fastqs = find_fastqs
output:
mapped = "output/{sample}_mapped.bam"
params:
ref = "refs/AF086833.fa"
shell:
"bwa mem {params.ref} {input.fastqs} | samtools sort > {output.mapped}"
Uses an input function to find the correct samples for rule bwa. There might be a more elegant solution, but I can't see it right now. I think this should work, though.
(Edited to reflect OP's edit.)
Unfortunately, I've also had this problem with filenames with the following logic: {batch}/{seq_run}_{index}_{flowcell}_{lane}_{read_orientation}.fastq.gz.
I think that the core problem is that none of the individual wildcards are unique. Also, not all values for all wildcards can be combined; seq_run1 was run on lane1, not lane2. Therefore, expand() does not work.
After multiple attempts in Snakemake (see below), my solution was to standardize input with mv / sed / rename. Removing {batch}, {flowcell} and {lane} made it possible to use {sample}, a unique combination of {seq_run} and {index}.
What did not work (but it could be worth to try for others in the same situation):
Adding the zip argument to expand()
Renaming output using the following syntax:
output: "_".join(re.split("[/_]", "{full_filename}")[1,2]+".fastq.gz"

How to query GCC warnings for C++?

GCC allows querying available warning flags specific for C++ language with the syntax:
g++ -Q --help=warning,c++
Adding warning flags to the call includes them in the result:
g++ -Wall -Q --help=warning,c++
However, it seems the call is done from the C point of view and I don't know how to do it from the C++ point of view. If the call includes C++-only warning, like:
g++ -Wnon-virtual-dtor -Q --help=warning,c++
the output contains a message:
cc1: warning: command line option ‘-Wnon-virtual-dtor’ is valid for C++/ObjC++ but not for C
and still shows the warning as disabled:
-Wnon-virtual-dtor [disabled]
Note, that this happens regardless of whether the call is done using g++ or gcc.
The same with C-only -Wbad-function-cast behaves in an expected way:
gcc -Wbad-function-cast -Q --help=warning,c
There is no extra message and reported warning status changes between [disabled] and [enabled]. Again, regardless of whether g++ or gcc is used.
I'm using GCC version 7.3.0. Although the issue seems to apply to many if not all versions. It can be observed through Compiler Explorer.
So, is there a way to do this query with respect to given language?
Yes, your observations are correct.
Probably this is not the intended behavior, and if you care about this feature, then I suggest reporting it upstream.
Note that this works, however:
touch 1.cc
g++ -Wnon-virtual-dtor -Q --help=warning,c++ 1.cc
I.e. if there's an input file with a proper extension, then the correct compiler proper executable is invoked: cc1plus, not cc1. The latter is the default if no input files are present. I did some quick debugging, and here's how that happens:
// gcc.c:
driver::do_spec_on_infiles () const
{
...
for (i = 0; (int) i < n_infiles; i++)
{
...
/* Figure out which compiler from the file's suffix. */
input_file_compiler
= lookup_compiler (infiles[i].name, input_filename_length,
infiles[i].language);
if (input_file_compiler)
{
...
value = do_spec (input_file_compiler->spec);
And input_file_compiler at that point is the C compiler, because
p n_infiles
$9 = 1
(gdb) p infiles[0]
$10 = {name = 0x4cbfb0 "help-dummy", language = 0x4cbfae "c", incompiler = 0x58a920, compiled = false, preprocessed = false}
Here's how the dummy file got created (function process_command in the same file):
if (n_infiles == 0
&& (print_subprocess_help || print_help_list || print_version))
{
/* Create a dummy input file, so that we can pass
the help option on to the various sub-processes. */
add_infile ("help-dummy", "c");
}

GNU Make: How to perform second expansion with suffix-changing substitution

What I'm going for (what's failing)
I have a list of dependencies for each file:
point_deps =
bounds_deps = point
triangle_deps = point bounds
Image_deps = types bounds triangle
main_deps = Image triangle bounds point types
I'd like to write a rule to include the relevant dependencies. Here's my best attempt:
out/%.o: src/%.cpp src/%.h $$($$*_deps:%=src/%.h)
g++ -o $# -c $<
I expect $* to evaluate to, for instance, "main". Then the suffix-changing substitution should change each entry in the dependency list to begin with "src/" and end with ".h".
When I try to run the code above, I get an error (on the out/%.o line):
makefile:26: *** multiple target patterns. Stop.
What's working (non-optimal)
For now I have to create a separate variable for each file's header dependencies:
point_deps_h = $(point_deps:%=src/%.h)
bounds_deps_h = $(bounds_deps:%=src/%.h)
triangle_deps_h = $(triangle_deps:%=src/%.h)
Image_deps_h = $(Image_deps:%=src/%.h)
main_deps_h = $(main_deps:%=src/%.h)
Then I can use secondary-expansion to include the correct header files:
out/%.o: src/%.cpp src/%.h $$($$*_deps_h)
g++ -o $# -c $<

Workaround for Scala Error: The command line is too long?

I'm trying to compile someone's mod of minecraft so that I can make some changes to it. It uses scala somewhere in the recompiling, and I get this error:
== ERRORS FOUND in SCALA CODE ==
The command line is too long.
================================
I tend to agree:
'"scalac.bat" -encoding UTF-8 -deprecation -target:jvm-1.6 -classpath "jars\vers
ions\1.8.1\1.8.1.jar;lib;lib\*;lib;lib\*;jars\bin\minecraft.jar;jars\bin\jinput.
jar;jars\bin\lwjgl.jar;jars\bin\lwjgl_util.jar;jars\libraries\net\java\jinput\ji
nput\2.0.5\jinput-2.0.5.jar;jars\libraries\org\lwjgl\lwjgl\lwjgl-platform\2.9.1\
lwjgl-platform-2.9.1-natives-windows.jar;jars\libraries\com\ibm\icu\icu4j-core-m
ojang\51.2\icu4j-core-mojang-51.2.jar;jars\libraries\tv\twitch\twitch-external-p
latform\4.5\twitch-external-platform-4.5-natives-windows-64.jar;jars\libraries\c
om\sixense\SixenseJavaLibrary\062612.0\SixenseJavaLibrary-062612.0-natives-windo
ws.jar;jars\libraries\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.ja
r;jars\libraries\org\apache\logging\log4j\log4j-api\2.0-beta9\log4j-api-2.0-beta
9.jar;jars\libraries\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.
jar;jars\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;jars\libraries\
com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;jars\libra
ries\net\sf\jopt-simple\jopt-simple\4.6\jopt-simple-4.6.jar;jars\libraries\com\g
oogle\guava\guava\17.0\guava-17.0.jar;jars\libraries\commons-logging\commons-log
ging\1.1.3\commons-logging-1.1.3.jar;jars\libraries\org\apache\commons\commons-c
ompress\1.8.1\commons-compress-1.8.1.jar;jars\libraries\com\sixense\SixenseJava\
062612.1\SixenseJava-062612.1.jar;jars\libraries\tv\twitch\twitch\6.5\twitch-6.5
.jar;jars\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;
jars\libraries\optifine\OptiFine\1.8.1_HD_U_B2\OptiFine-1.8.1_HD_U_B2.jar;jars\l
ibraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;jars\librar
ies\org\json\json\20140107\json-20140107.jar;jars\libraries\com\paulscode\librar
ylwjglopenal\20100824\librarylwjglopenal-20100824.jar;jars\libraries\org\lwjgl\l
wjgl\lwjgl_util\2.9.1\lwjgl_util-2.9.1.jar;jars\libraries\commons-codec\commons-
codec\1.9\commons-codec-1.9.jar;jars\libraries\org\apache\httpcomponents\httpcli
ent\4.3.3\httpclient-4.3.3.jar;jars\libraries\de\fruitfly\ovr\JRiftLibrary\0.4.4
.1\JRiftLibrary-0.4.4.1-natives-windows.jar;jars\libraries\org\lwjgl\lwjgl\lwjgl
\2.9.1\lwjgl-2.9.1.jar;jars\libraries\commons-io\commons-io\2.4\commons-io-2.4.j
ar;jars\libraries\com\mojang\realms\1.7.4\realms-1.7.4.jar;jars\libraries\net\ai
b42\mumblelink\JMumbleLibrary\1.1\JMumbleLibrary-1.1-natives-windows.jar;jars\li
braries\com\mojang\authlib\1.5.17\authlib-1.5.17.jar;jars\libraries\com\google\c
ode\gson\gson\2.2.4\gson-2.2.4.jar;jars\libraries\net\minecraft\launchwrapper\1.
7\launchwrapper-1.7.jar;jars\libraries\com\paulscode\codecwav\20101023\codecwav-
20101023.jar;jars\libraries\tv\twitch\twitch-platform\6.5\twitch-platform-6.5-na
tives-windows-64.jar;jars\libraries\net\java\jinput\jinput-platform\2.0.5\jinput
-platform-2.0.5-natives-windows.jar;jars\libraries\de\fruitfly\ovr\JRift\0.4.4.1
\JRift-0.4.4.1.jar;jars\libraries\org\apache\logging\log4j\log4j-core\2.0-beta9\
log4j-core-2.0-beta9.jar;jars\libraries\net\aib42\mumblelink\JMumble\1.0\JMumble
-1.0.jar;jars\libraries\io\netty\netty-all\4.0.23.Final\netty-all-4.0.23.Final.j
ar" -sourcepath src\minecraft -d bin\minecraft src\minecraft\*.java src\minecraf
t\net\minecraft\block\*.java src\minecraft\net\minecraft\block\material\*.java s
rc\minecraft\net\minecraft\block\properties\*.java src\minecraft\net\minecraft\b
lock\state\*.java src\minecraft\net\minecraft\block\state\pattern\*.java src\min
ecraft\net\minecraft\client\*.java src\minecraft\net\minecraft\client\audio\*.ja
va src\minecraft\net\minecraft\client\entity\*.java src\minecraft\net\minecraft\
client\gui\*.java src\minecraft\net\minecraft\client\gui\achievement\*.java src\
minecraft\net\minecraft\client\gui\inventory\*.java src\minecraft\net\minecraft\
client\gui\spectator\*.java src\minecraft\net\minecraft\client\gui\spectator\cat
egories\*.java src\minecraft\net\minecraft\client\gui\stream\*.java src\minecraf
t\net\minecraft\client\main\*.java src\minecraft\net\minecraft\client\model\*.ja
va src\minecraft\net\minecraft\client\multiplayer\*.java src\minecraft\net\minec
raft\client\network\*.java src\minecraft\net\minecraft\client\particle\*.java sr
c\minecraft\net\minecraft\client\player\inventory\*.java src\minecraft\net\minec
raft\client\renderer\*.java src\minecraft\net\minecraft\client\renderer\block\mo
del\*.java src\minecraft\net\minecraft\client\renderer\block\statemap\*.java src
\minecraft\net\minecraft\client\renderer\chunk\*.java src\minecraft\net\minecraf
t\client\renderer\culling\*.java src\minecraft\net\minecraft\client\renderer\ent
ity\*.java src\minecraft\net\minecraft\client\renderer\entity\layers\*.java src\
minecraft\net\minecraft\client\renderer\texture\*.java src\minecraft\net\minecra
ft\client\renderer\tileentity\*.java src\minecraft\net\minecraft\client\renderer
\vertex\*.java src\minecraft\net\minecraft\client\resources\*.java src\minecraft
\net\minecraft\client\resources\data\*.java src\minecraft\net\minecraft\client\r
esources\model\*.java src\minecraft\net\minecraft\client\settings\*.java src\min
ecraft\net\minecraft\client\shader\*.java src\minecraft\net\minecraft\client\str
eam\*.java src\minecraft\net\minecraft\client\util\*.java src\minecraft\net\mine
craft\command\*.java src\minecraft\net\minecraft\command\common\*.java src\minec
raft\net\minecraft\command\server\*.java src\minecraft\net\minecraft\crash\*.jav
a src\minecraft\net\minecraft\creativetab\*.java src\minecraft\net\minecraft\dis
penser\*.java src\minecraft\net\minecraft\enchantment\*.java src\minecraft\net\m
inecraft\entity\*.java src\minecraft\net\minecraft\entity\ai\*.java src\minecraf
t\net\minecraft\entity\ai\attributes\*.java src\minecraft\net\minecraft\entity\b
oss\*.java src\minecraft\net\minecraft\entity\effect\*.java src\minecraft\net\mi
necraft\entity\item\*.java src\minecraft\net\minecraft\entity\monster\*.java src
\minecraft\net\minecraft\entity\passive\*.java src\minecraft\net\minecraft\entit
y\player\*.java src\minecraft\net\minecraft\entity\projectile\*.java src\minecra
ft\net\minecraft\event\*.java src\minecraft\net\minecraft\init\*.java src\minecr
aft\net\minecraft\inventory\*.java src\minecraft\net\minecraft\item\*.java src\m
inecraft\net\minecraft\item\crafting\*.java src\minecraft\net\minecraft\nbt\*.ja
va src\minecraft\net\minecraft\network\*.java src\minecraft\net\minecraft\networ
k\handshake\*.java src\minecraft\net\minecraft\network\handshake\client\*.java s
rc\minecraft\net\minecraft\network\login\*.java src\minecraft\net\minecraft\netw
ork\login\client\*.java src\minecraft\net\minecraft\network\login\server\*.java
src\minecraft\net\minecraft\network\play\*.java src\minecraft\net\minecraft\netw
ork\play\client\*.java src\minecraft\net\minecraft\network\play\server\*.java sr
c\minecraft\net\minecraft\network\status\*.java src\minecraft\net\minecraft\netw
ork\status\client\*.java src\minecraft\net\minecraft\network\status\server\*.jav
a src\minecraft\net\minecraft\pathfinding\*.java src\minecraft\net\minecraft\pot
ion\*.java src\minecraft\net\minecraft\profiler\*.java src\minecraft\net\minecra
ft\realms\*.java src\minecraft\net\minecraft\scoreboard\*.java src\minecraft\net
\minecraft\server\*.java src\minecraft\net\minecraft\server\gui\*.java src\minec
raft\net\minecraft\server\integrated\*.java src\minecraft\net\minecraft\server\m
anagement\*.java src\minecraft\net\minecraft\server\network\*.java src\minecraft
\net\minecraft\src\*.java src\minecraft\net\minecraft\stats\*.java src\minecraft
\net\minecraft\tileentity\*.java src\minecraft\net\minecraft\util\*.java src\min
ecraft\net\minecraft\village\*.java src\minecraft\net\minecraft\world\*.java src
\minecraft\net\minecraft\world\biome\*.java src\minecraft\net\minecraft\world\bo
rder\*.java src\minecraft\net\minecraft\world\chunk\*.java src\minecraft\net\min
ecraft\world\chunk\storage\*.java src\minecraft\net\minecraft\world\demo\*.java
src\minecraft\net\minecraft\world\gen\*.java src\minecraft\net\minecraft\world\g
en\feature\*.java src\minecraft\net\minecraft\world\gen\layer\*.java src\minecra
ft\net\minecraft\world\gen\structure\*.java src\minecraft\net\minecraft\world\pa
thfinder\*.java src\minecraft\net\minecraft\world\storage\*.java src\minecraft\o
ptifine\*.java src\minecraft\optifine\json\*.java' failed : 1
Given that windows has a character limit on the command line.
I'm using windows 8.1 and scala 2.11.0.
I was wondering, is there a way to set this as an environment/path variable or something to avoid this?
What would I have to change? I'm very new to messing around with system stuff like this, but I think I know where scala is called in the scripts and this argument is given. If that helps.
scalac accepts an #file parameter containing a file with arguments in. So if you can modify whatever script is calling scalac.bat to instead put the arguments in a temporary file arguments.txt and then call scalac #arguments.txt that should work.

Resources