You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: asciidocs/channels.adoc
+298Lines changed: 298 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -360,3 +360,301 @@ process fastqc {
360
360
}
361
361
----
362
362
363
+
=== Text files
364
+
365
+
The `splitText` operator allows you to split multi-line strings or text file items, emitted by a source channel into chunks containing n lines, which will be emitted by the resulting channel. See:
366
+
367
+
----
368
+
Channel
369
+
.fromPath('data/meta/random.txt') // <1>
370
+
.splitText() // <2>
371
+
.view() // <3>
372
+
----
373
+
374
+
<1> Instructs Nextflow to make a channel from the path "data/meta/random.txt".
375
+
<2> The `splitText` operator splits each item into chunks of one line by default.
376
+
<3> View contents of the channel.
377
+
378
+
379
+
You can define the number of lines in each chunk by using the parameter `by`, as shown in the following example:
380
+
381
+
----
382
+
Channel
383
+
.fromPath('data/meta/random.txt')
384
+
.splitText( by: 2 )
385
+
.subscribe {
386
+
print it;
387
+
print "--- end of the chunk ---\n"
388
+
}
389
+
----
390
+
391
+
TIP: The `subscribe` operator permits to execute a user defined function each time a new value is emitted by the source channel.
392
+
393
+
An optional closure can be specified in order to transform the text chunks produced by the operator. The following example shows how to split text files into chunks of 10 lines and transform them into capital letters:
Finally, you can also use the operator on plain files (outside of the channel context), as so:
415
+
416
+
----
417
+
def f = file('data/meta/random.txt')
418
+
def lines = f.splitText()
419
+
def count=0
420
+
for( String row : lines ) {
421
+
log.info "${count++} ${row.toUpperCase()}"
422
+
}
423
+
----
424
+
425
+
=== Comma separate values (.csv)
426
+
427
+
The `splitCsv` operator allows you to parse text items emitted by a channel, that are formatted using the CSV format.
428
+
429
+
It then splits them into records or groups them into a list of records with a specified length.
430
+
431
+
In the simplest case, just apply the `splitCsv` operator to a channel emitting a CSV formatted text files or text entries, to view only the first and fourth columns. For example:
432
+
433
+
----
434
+
Channel
435
+
.fromPath("data/meta/patients_1.csv")
436
+
.splitCsv()
437
+
// row is a list object
438
+
.view { row -> "${row[0]},${row[3]}" }
439
+
----
440
+
441
+
When the CSV begins with a header line defining the column names, you can specify the parameter `header: true` which allows you to reference each value by its name, as shown in the following example:
Copy file name to clipboardExpand all lines: asciidocs/containers.adoc
+1-6Lines changed: 1 addition & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -381,12 +381,7 @@ Conda is a popular package and environment manager. The built-in support for Con
381
381
allows Nextflow pipelines to automatically create and activate the Conda
382
382
environment(s), given the dependencies specified by each process.
383
383
384
-
For this Gitpod tutorial you need to activate conda by typing:
385
-
386
-
387
-
```bash
388
-
conda_activate
389
-
```
384
+
For this Gitpod tutorial you need to open a new terminal to ensure that conda is activated (see the + button on the terminal).
390
385
391
386
You should now see that the beginning of your command prompt has `(base)` written. If you wish to deactivate conda at any point, simply enter `conda deactivate`.
0 commit comments