5.Python
Python Tutorial

Install Anaconda Python

Python language tips
Compatibility between Python 3.x and Python 2.x
Get away from IndentationError
Add Shebang and encoding at the beginning of executable scripts
All variables, functions, classes are dynamic objects
All python variables are pointers/references
Use deepcopy if you really want to COPY a variable
deepcopy if you really want to COPY a variableWhat if I accidentally overwrite my builtin functions?
int is of arbitrary precision in Python!
int is of arbitrary precision in Python!Easiest way to swap values of two variables
List comprehension
Dict comprehension
For the one-liners
Read from standard input
Order of dict keys are NOT as you expected
Use enumerate() to add a number during iteration
Reverse a list
Strings are immutable in Python
tuples are hashable while lists are not hashable
Use itertools
Convert iterables to lists
Use the zip() function to transpose nested lists/tuples/iterables
Global and local variables
Use defaultdict
Use generators
Turn off annoying KeyboardInterrupt and BrokenPipe Error
Class and instance variables
Useful Python packages for data analysis
Browser-based interactive programming in Python: jupyter










Python packages for scientific computing

Vector arithmetics: numpy
Numerical analysis (probability distribution, signal processing, etc.): scipy
Just-in-time (JIT) compiler for vector arithmetics
Library for symbolic computation: sympy

Operation on data frames: pandas
Basic graphics and plotting: matplotlib

Statistical data visualization: seaborn

Interactive programming in Python: ipython

Statistical tests: statsmodels

Machine learning algorithms: scikit-learn

Natural language analysis: gensim
HTTP library: requests

Lightweight Web framework: flask

Deep learning framework: tensorflow
High-level deep learning framework: keras
Operation on sequence and alignment formats: biopython
Operation on genomic formats (BigWig,etc.): bx-python
Operation on HDF5 files: h5py
Mixed C/C++ and python programming: cython
Progress bar: tqdm


Example Python scripts
View a table in a pretty way
Generate a random FASTA file
Weekly tasks
Video
Last updated
