Difference between revisions of "User:Jarle Pahr/Programming"
|Line 246:||Line 246:|
====Keywords and statements====
====Keywords and statements====
Revision as of 06:23, 7 April 2013
CodeEval - programming challenges: http://codeeval.com
http://software-carpentry.org/ - Learn scientific programming.
- 1 Concepts/glossary:
- 2 Languages
- 2.1 C
- 2.2 Python
- 2.2.1 Official documentation
- 2.2.2 Learning Python
- 2.2.3 Misc
- 2.2.4 Differences between Python 2 and Python 3
- 2.2.5 Q&A /How-tos
- 2.2.6 Modules and libraries
- 2.3 Perl
- List comprehension: http://en.wikipedia.org/wiki/List_comprehension
- Dynamic-link library: "DLLs provide a mechanism for shared code and data, allowing a developer of shared code/data to upgrade functionality without requiring applications to be re-linked or re-compiled." (Wikipedia).
- Shell: "Software that provides and interface for users of an operating system to acess the services of a kernel" (Wikipedia). Typically, a graphical user interface (GUI) or a command-line interface (CLI). Examples: Windows Explorer (GUI), Windows Command Prompt (cmd.exe) (CLI), COMMAND.COM in DOS (CLI).
- Shell script: "A script written for the shell, or command line interpreter, of an operating system." (Wikipedia)
- IDE: Integrated Development Environment. Software application facilitating programming.
- Garbage collection: Freeing of memory that is not used anymore.
- Interpreter: A computer program that executes instructions written in a programming language.
- Interpreted language: Language where programs can be run by an interpreter. Code must not be explicitly compilated (turned into an executable) in order to be run. MATLAB, Perl and Python are examples of interpreted languages. Interpreted programs typically run slower than compiled programs.
- Scripting language: "a programming language that supports the writing of scripts, programs written for a software environment that automate the execution of tasks" (Wikipedia). Typical features are ease of use, OS facilities, interpreted from source code, loose structure.
- Dynamic programming language: "a class of high-level programming languages that execute at runtime many common behaviors that other languages might perform during compilation, if at all." (Wikipedia). MATLAB, Perl, Python and R are dynamic programming languages. Not to be confused with dynamically typed language.
- Type (Data Type): "lassification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of that type can be stored." (Wikipedia)
- Type system: " a collection of rules that assign a property called a type to the various constructs—such as variables, expressions, functions or modules—a computer program is composed of." (Wikipedia)
- Dynamically typed language: "A programming language is said to be dynamically typed when the majority of its type checking is performed at run-time as opposed to at compile-time. In dynamic typing values have types, but variables do not; that is, a variable can refer to a value of any type." (Wikipedia) Python and Perl are dynamically typed languages.
- Run time: "the time during which a program is running (executing), in contrast to other phases of a program's lifecycle such as compile time, link time, load time, etc. A run-time error is detected after or during the execution of a program, whereas a compile-time error is detected by the compiler before the program is ever executed." (Wikipedia
- Software library: " a collection of implementations of behavior, written in terms of a language, that has a well-defined interface by which the behavior is invoked.(...) Library code is organized in such a way that it can be used by multiple programs that have no connection to each other, while code that is part of a program is organized to only be used within that one program(...) A library is organized for the purposes of being reused by independent programs or sub-programs, and the user only needs to know the interface, and not the internal details of the library."
- Imperative programming/Imperative language: "A programming paradigm that describes computation in terms of statements that change a program state(...). The term is used in opposition to declarative programming, which expresses what the program should accomplish without prescribing how to do it in terms of sequences of actions to be taken" (Wikipedia). Examples of imperative languages are C, C++, Java, COBOL and FORTRAN.
- Object-oriented programming: "A programming paradigm that represents concepts as "objects" that have data fields (attributes that describe the object) and associated procedures known as methods." (Wikipedia)
Python standard library (Python 3.3): http://docs.python.org/3.3/library/
Python 2. 7 Documentation: http://docs.python.org/2.7/
Python 3.3 tutorial: http://docs.python.org/3.3/tutorial/
Python 3.3 glossary: http://docs.python.org/3.3/glossary.html#glossary
Python on Windows FAQ: http://docs.python.org/3.3/faq/windows.html
Python 3.3 Built-in functions: http://docs.python.org/3.3/library/functions.html#execfile
Beginning Python for bioinformatics Wiki: http://wiki.genedrift.org
Bioinformatics Programming Using Python Practical Programming for Biological Data: http://shop.oreilly.com/product/9780596154516.do?
Article: Programming biological models in Python using PySB /doku.php?id=beginning_python_for_bioinformatics
Stackoverflow - Python questions: http://stackoverflow.com/questions/tagged/python
Python books: http://wiki.python.org/moin/IntroductoryBooks
Python basic syntax: http://www.tutorialspoint.com/python/python_basic_syntax.htm
Simple Python programs: http://wiki.python.org/moin/SimplePrograms
About Python shells: http://python.about.com/od/programmingglossary/g/defshell.htm
Popular Python recipes: http://code.activestate.com/recipes/langs/python/
O'reilly Python devcenter: http://www.onlamp.com/python/
Differences between Python 2 and Python 3
- Print is changed from a statement (print "something") to a function (print("something"))
- raw_input() is replaced by input()
Modules and libraries
NumPy & SciPy
SciPy is a packafe for scientific computing which depends on the NumPy package.
Projects using NumPy and/or SciPy: http://www.scipy.org/Projects
NumPy & SciPy FAQ: http://www.scipy.org/FAQ
Biology & Bioinformatics
Biopython tutorial: http://biopython.org/DIST/docs/tutorial/Tutorial.html
PyPI - Python package index: https://pypi.python.org/pypi
Python.org - useful modules: http://wiki.python.org/moin/UsefulModules
PyLab is part of matplotlib: http://stackoverflow.com/questions/12987624/confusion-between-numpy-scipy-matplotlib-and-pylab
iPython Notebook viewer: http://nbviewer.ipython.org/
To launch iPython Notebook, write "ipython notebook" at the Windows command line (cmd.exe).
EPD free edition: http://www.enthought.com/products/epd_free.php
Includes Python, iPython, IDLE, matplotlib, numpy and SciPy.
Includes NumPy, SciPy, matplotlib and Spyder.
string.split("delimiter"): Splits a string into a list of strings. Ex: sequenc = ATGCA seq = sequence.split("G") --> seq = ['AT', 'CA']
list.append(x): Append object x to the end of list.
list.reverse(): Reverse order of elements in a list.
"".join(list): Join list elements into a string.
Slice: slice(stop) slice(start, stop[, step])
"Returns a slice object representing the set of indices specified by range(start, stop, step)"
dictionary.item() Returns an array of tuples with each tuple consisting of a key/value pair from the dictionary:
Anonymous functions/lambda functions:
filter(function, iterable): Constructs a list from those elements of iterable for which the condition in function evaluates to true.
Keywords and statements
with ... as
Tips & Tricks
To stay in the Python interpreter environment after running a script, add - i before the script name: python -i script.py
A list can be reversed by the reverse function, or by list slicing with a negative stride:
backwards = my_list[::-1]
According to Wikipedia, Perl is "a high-level, general-purpose, interpreted, dynamic programming language."
Beginning Perl for Bioinformatics: http://shop.oreilly.com/product/9780596000806.do
A "hash" in perl is the equivalent of a "dictionary" in Python.