Skip to content

Commit c853ce3

Browse files
committed
updated examples
1 parent 7f1fab0 commit c853ce3

File tree

4 files changed

+146
-6
lines changed

4 files changed

+146
-6
lines changed

examples/more_examples.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
3+
kscript - test2.fastq <<"EOF"
4+
java.io.File(args[0]).useLines {
5+
it.map {
6+
if (!it.startsWith(">")) it else "huhu" + it
7+
}.forEach { println(it) }
8+
}
9+
EOF
10+
11+
12+
13+
14+
kscript - <<"EOF"
15+
println("getting started")
16+
generateSequence() { readLine() }.map {
17+
if (!it.startsWith(">")) it else
18+
"huhu" + it
19+
}.forEach { println(it) }
20+
EOF
21+
22+
23+
head -n 1000 test.fastq > test2.fastq
24+
25+
26+
## how use stdin but still use heredoc for cod
27+
kscript - test2.fastq <(echo <<"EOF"
28+
println("getting started")
29+
//generateSequence() { readLine() }.map {
30+
File(args[0]).readLines().map {
31+
if (!it.startsWith(">")) it else
32+
"huhu" + it
33+
}.forEach { println(it) }
34+
EOF
35+
)
36+
37+
38+
39+
## todo provide picard tools examples
40+
http://mvnrepository.com/artifact/com.github.broadinstitute/picard/2.5.0
41+
potentially like
42+
https://www.biostars.org/p/52698/
43+
44+
45+
## simplified line streaming
46+
47+
48+
49+
fun main(args: Array<String>) {
50+
kutils.KscriptHelpers.processStdin { "huhu" + it }
51+
}
52+
53+
54+
kscript -s '
55+
//DEPS de.mpicbg.scicomp:kutils:0.2-SNAPSHOT
56+
kutils.KscriptHelpers.processStdin { "huhu" + it }
57+
58+
'
59+
60+
## todo streamline further by using simple code wrapper for (see https://github.com/holgerbrandl/kscript/issues/9)
61+
kscript -st '"huhu" + it'
62+
63+
64+
## REPL test: Filter-Join fasta files by ID
65+
kotlinc -classpath $(expandcp.kts de.mpicbg.scicomp:kutils:0.2-SNAPSHOT)
66+
<<"EOF"
67+
68+
69+
kutils.KscriptHelpers.processStdin { "huhu" + it }
70+
kscript
71+
72+
EOF

examples/scratchpad.kts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env kscript
2+
3+
import de.mpicbg.scicomp.kscript.processLines
4+
5+
println("ok")
6+
println(args.joinToString())
7+
8+
// test
9+
10+
11+
//generateSequence() { readLine() }.map {
12+
//File(args[0]).readLines().map {}
13+
14+
java.io.File(args[0]).useLines {
15+
it.map {
16+
if (!it.startsWith(">")) {
17+
it.substring(0, 20)
18+
} else it
19+
}.forEach { println(it) }
20+
}
21+
22+
23+
java.io.File(args[0]).processLines { it + "foo" }
24+

examples/test.kts

Lines changed: 0 additions & 5 deletions
This file was deleted.

pom.xml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<groupId>kscript</groupId>
77
<version>1.0-SNAPSHOT</version>
88

9+
<properties>
10+
<kotlin.version>1.0.3</kotlin.version>
11+
</properties>
12+
913

1014
<dependencies>
1115
<dependency>
@@ -17,8 +21,53 @@
1721
<dependency>
1822
<groupId>de.mpicbg.scicomp</groupId>
1923
<artifactId>kutils</artifactId>
20-
<version>0.2-SNAPSHOT</version>
24+
<version>0.2</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.jetbrains.kotlin</groupId>
28+
<artifactId>kotlin-stdlib</artifactId>
29+
<version>${kotlin.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.jetbrains.kotlin</groupId>
33+
<artifactId>kotlin-test</artifactId>
34+
<version>${kotlin.version}</version>
35+
<scope>test</scope>
2136
</dependency>
2237

2338
</dependencies>
39+
40+
<build>
41+
<plugins>
42+
<plugin>
43+
<groupId>org.jetbrains.kotlin</groupId>
44+
<artifactId>kotlin-maven-plugin</artifactId>
45+
<version>${kotlin.version}</version>
46+
<executions>
47+
<execution>
48+
<id>compile</id>
49+
<phase>compile</phase>
50+
<goals>
51+
<goal>compile</goal>
52+
</goals>
53+
<configuration>
54+
<sourceDirs>
55+
<source>examples</source>
56+
<source></source>
57+
</sourceDirs>
58+
</configuration>
59+
</execution>
60+
<execution>
61+
<id>test-compile</id>
62+
<phase>test-compile</phase>
63+
<goals>
64+
<goal>test-compile</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
72+
2473
</project>

0 commit comments

Comments
 (0)