-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update lib docs #5492
base: master
Are you sure you want to change the base?
Update lib docs #5492
Conversation
Signed-off-by: Christopher Hakkaart <[email protected]>
✅ Deploy Preview for nextflow-docs-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I think that the
The "Any Groovy scripts" feels a bit too loosely defined. The directory is added to the classpath, which means that any classes or packages defined therein will be available in the execution context. Loose scripts, or functions defined outside of classes will not be available to Nextflow. You can load arbitrary assets in this workflow {
def myFile = this.class.classLoader.getResource("my-file.txt")
println = myFile?.text
} But imho, this should be discouraged. It should be used for loading classes and packages only, and the documentation should encourage this by making it explicit that the |
@pditommaso has also noted internally that the |
All good. I've converted this PR to a draft and re-work it to focus on documenting best practises for the lib directory. |
Potential example: // lib/DNASequence.groovy
class DNASequence {
String sequence
// Constructor
DNASequence(String sequence) {
this.sequence = sequence.toUpperCase() // Ensure sequence is in uppercase for consistency
}
// Method to calculate melting temperature using the Wallace rule
double getMeltingTemperature() {
int gCount = sequence.count('G')
int cCount = sequence.count('C')
int aCount = sequence.count('A')
int tCount = sequence.count('T')
// Wallace rule calculation
double tm = 4 * (gCount + cCount) + 2 * (aCount + tCount)
return tm
}
String toString() {
return "DNA[$sequence]"
}
} // main.nf
workflow {
Channel.of('ACGTTGCAATGCCGTA', 'GCGTACGGTACGTTAC')
.map { seq -> new DNASequence(seq) }
.view { dna ->
def meltTemp = dna.getMeltingTemperature()
"Found sequence '$dna' with melting temperaure ${meltTemp}°C"
}
} Which returns
|
Signed-off-by: Christopher Hakkaart <[email protected]>
Signed-off-by: Christopher Hakkaart <[email protected]>
Thanks for the example. I've updated the PR with the example and a revised lib section. The sentence "Scripts or functions defined outside of classes will not be available in the execution context." could be made into a warning either before or after the example if you think it should be more prominent. |
int gCount = sequence.count('G') | ||
int cCount = sequence.count('C') | ||
int aCount = sequence.count('A') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but hard to read those variables maybe g_count
or gc
is a better alternative
int gCount = sequence.count('G') | ||
int cCount = sequence.count('C') | ||
int aCount = sequence.count('A') | ||
int tCount = sequence.count('T') | ||
|
||
// Wallace rule calculation | ||
double tm = 4 * (gCount + cCount) + 2 * (aCount + tCount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int gCount = sequence.count('G') | |
int cCount = sequence.count('C') | |
int aCount = sequence.count('A') | |
int tCount = sequence.count('T') | |
// Wallace rule calculation | |
double tm = 4 * (gCount + cCount) + 2 * (aCount + tCount) | |
int g_count = sequence.count('G') | |
int c_count = sequence.count('C') | |
int a_count = sequence.count('A') | |
int t_count = sequence.count('T') | |
// Wallace rule calculation | |
double tm = 4 * (g_count + c_count) + 2 * (a_count + t_count) |
@robsyme does this work for you?
-lib
in lib sharing sectionlib
directory section to cli users sectioncc @robsyme