|
|
|
This page is not meant to tell you all about general coding practices but it aims at listing points that we (MIB bioinfo) find important. The ultimate goal is to improve code readability and make it easy for others to work with or modify our scripts. It is good to take a look at this page before starting sharing your code. The coding conventions of the language you use to develop always applies unless stated differently in this document.
|
|
|
|
|
|
|
|
> for idx >= 1 becomes for 1 <= idx
|
|
|
|
|
|
|
|
Naming rule
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
**Meaningful name:** Variable names should be easy to understand, short and representative of the data they store. The way you name your variables is key to making your code readable. Make variable names self-explanatory and consistent with the theme of the script.
|
|
|
|
|
|
|
|
**Short name:** Try making the variable name as short as possible, avoid the use of separators like (- _ / \ & + . ,) in the variable names. Follow the [camelCase](https://en.wikipedia.org/wiki/Camel_case) notation and variable name always starts with lower case.
|
|
|
|
|
|
|
|
**For example:** If you write a script to assemble 'FASTQ' files, avoid using variable like, input1 input2 rather call it what it is forwardRead, reverseRead or fastqFile.
|
|
|
|
|
|
|
|
**Function & Class:** Function and Class name follow the same idea as for variable name with the exception that for class names the 1st letter is capitalised.
|
|
|
|
For example, thisIsFunction but ThisIsClass.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Documentation & comments
|
|
|
|
--------------------------
|
|
|
|
|
|
|
|
Comments are parts of your script that are never interpreted by the computer and Documentation is a specific part of the comments that describes general purpose of the entire script or just specific functions. Documentation are more formal and can sometimes be used to general manual.
|
|
|
|
|
|
|
|
```
|
|
|
|
USAGE
|
|
|
|
-----
|
|
|
|
Here comes an example of a short command that could be used to test the script
|
|
|
|
template.py -i ../test-data/input.file -o ../test-data/output.file [--threshold 2]
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
This script is a template that give an idea what a shared MIB script should look like.
|
|
|
|
Please modify it to your taste.
|
|
|
|
This section should have an extensive description of what the script does, it will be
|
|
|
|
used to make a list of all the scripts and their description.
|
|
|
|
|
|
|
|
It is important that your script uses python 3.6
|
|
|
|
|
|
|
|
PROGRAMS
|
|
|
|
--------
|
|
|
|
Which third parties program are used in this script.
|
|
|
|
|
|
|
|
AUTHOR(S)
|
|
|
|
---------
|
|
|
|
Will Iam, will.iam@wur.nl
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Indentations
|
|
|
|
Portability
|
|
|
|
Reusability and scalability
|
|
|
|
Testing
|
|
|
|
|
|
|
|
https://www.thinkful.com/blog/coding-best-practices/ |
|
|
\ No newline at end of file |