User:Jarle Pahr/Programming

From OpenWetWare
Jump to navigationJump to search

CodeEval - programming challenges: http://codeeval.com

http://software-carpentry.org/ - Learn scientific programming.

www.codecademy.com


https://www.researchgate.net/post/What_programming_language_is_best_for_a_bioinformatics_beginner

http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/


Programming practices

http://en.wikipedia.org/wiki/Naming_convention_%28programming%29

Concepts/glossary

  • Application programming interface (API): "a protocol intended to be used as an interface by software components to communicate with each other. An API is a library that may include specification for routines, data structures, object classes, and variables" (http://en.wikipedia.org/wiki/Application_programming_interface)
  • Object code: The product of a compiler. May be in the form of machine code or an intermediate language.
  • Object: From Wikipedia: "In computer science, an object is a location in memory having a value and referenced by an identifier. An object can be a variable, function, or data structure. With the later introduction of object-oriented programming the same word, "object," refers to a particular instance of a class."
  • Getters & Setters:

A command for printing text to the terminal in several operating systems.

A class of decision problems belonging to the intersection of NP (nondeterministic poylynomial) problems and NP-hard problems. NP-complete problems have solutions which can be verified quickly, but for which there exists no efficient algorithms.

  • Single inheritance language:
  • Multiple inheritance language:
  • 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."
  • Statically typed:
  • 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.

See http://stackoverflow.com/questions/602444/what-is-functional-declarative-and-imperative-programming

  • 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)
  • Method

Languages

C

http://en.wikipedia.org/wiki/C_%28programming_language%29

Hello world in C:

#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("Hello, world!\n");
    return 0;
}

Objective-C

Objective-C is a general-purpose, high-level, object-oriented programming language (Wikipedia). Main programming language used by Apple for OS X and iOS. A superset of C - any C program can be compiled by an objective-C compiler.

From Wikipedia:

"Objective-C derives its object syntax from Smalltalk. All of the syntax for non-object-oriented operations (including primitive variables, pre-processing, expressions, function declarations, and function calls) are identical to that of C, while the syntax for object-oriented features is an implementation of Smalltalk-style messaging."

Java

Not to be confused with JavaScript. According to Wikipedia, "Java is a general-purpose, concurrent, class-based, object-oriented computer programming language." Furhter: "The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them."

  • Applications are combiled to bytecode that can run on a Java Virtual Machine.
  • Designed to have few implementation dependencies.

Ecclipse IDE: http://en.wikipedia.org/wiki/Eclipse_%28software%29


Learning Java

http://www.javaworld.com/jw-03-2000/jw-0331-java101.html

http://docs.oracle.com/javase/tutorial/java/

http://www.javabeginner.com/

Concepts

  • Class


Keywords

This: Refers to the current object. Used to refer to the current instance of the method on which it is used.

http://stackoverflow.com/questions/3728062/what-is-the-meaning-of-this-in-java

http://javapapers.com/core-java/explain-the-java-this-keyword/

https://en.wikipedia.org/wiki/This_%28computer_programming%29

Javascript

Not to be confused with Java. According to Wikipedia, " JavaScript copies many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics.(...) It is a multi-paradigm language, supporting object-oriented,[7] imperative, and functional[1][8] programming styles."

Functions

.substring

console.log()

Python

Official documentation

http://www.python.org/

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

Learning Python

Beginning Python for bioinformatics Wiki: http://wiki.genedrift.org

http://www.codecademy.com/tracks/python

Bioinformatics Programming Using Python Practical Programming for Biological Data: http://shop.oreilly.com/product/9780596154516.do?

http://python-course.eu/

http://www.python-course.eu/matrix_arithmetic.php

http://www.daniweb.com/software-development/python/114

http://en.wikibooks.org/wiki/Python_Programming

http://cafepy.com/

Misc

http://www.python.org/dev/peps/

http://stackoverflow.com/questions/4583367/how-to-run-multiple-python-version-on-windows

Article: Programming biological models in Python using PySB /doku.php?id=beginning_python_for_bioinformatics

http://ubuntuforums.org/showthread.php?t=127426

http://www.linuxtopia.org/online_books/programming_books/python_programming/python_ch20s05.html

http://www.syntagmatic.net/matrix-multiplication-in-python/

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

http://en.wikipedia.org/wiki/Python_syntax_and_semantics

Simple Python programs: http://wiki.python.org/moin/SimplePrograms

http://www.bin-co.com/blog/2008/03/python-hello-script/

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()

http://wiki.python.org/moin/Python2orPython3

http://docs.python.org/3/whatsnew/3.0.html

Q&A /How-tos

http://stackoverflow.com/questions/522563/accessing-the-index-in-python-for-loops

http://love-python.blogspot.no/2008/09/remove-duplicate-items-from-list-using.html

http://stackoverflow.com/questions/5711452/how-do-i-slice-a-string-every-3-indices

http://stackoverflow.com/questions/1303347/getting-a-map-to-return-a-list-in-python-3-1

http://stackoverflow.com/questions/674764/examples-for-string-find-in-python

http://stackoverflow.com/questions/8113684/python-itertools-permutations

http://www.petercollingridge.co.uk/python-tricks/list-comprehensions

http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python

http://stackoverflow.com/questions/434287/what-is-the-most-pythonic-way-to-iterate-over-a-list-in-chunks

http://code.activestate.com/recipes/499304-hamming-distance/

http://python.about.com/od/simplerscripts/qt/Getlinebynumber.htm

http://stackoverflow.com/questions/3939361/remove-specific-characters-from-a-string-in-python

http://stackoverflow.com/questions/118260/how-to-start-idle-python-editor-without-using-the-shortcut-on-windows-vista

http://stackoverflow.com/questions/9831097/is-open-read-safe

http://stackoverflow.com/questions/3173915/modification-of-the-list-items-in-the-loop-python

http://stackoverflow.com/questions/4081217/how-to-modify-list-entries-during-for-loop

http://stackoverflow.com/questions/3591807/how-can-i-stop-python-exe-from-closing-immediatly-after-i-get-an-output

http://stackoverflow.com/questions/6513967/running-python-script-from-idle-on-windows-7-64-bit

http://stackoverflow.com/questions/1027714/how-to-execute-a-file-within-the-python-interpreter

http://stackoverflow.com/questions/2545397/converting-a-string-into-a-list-in-python

http://stackoverflow.com/questions/12336105/python-reverse-list

http://stackoverflow.com/questions/4481724/python-convert-list-of-char-into-string

Printing commands:

http://stackoverflow.com/questions/11266068/python-avoid-new-line-with-print-command

http://docs.python.org/2/tutorial/inputoutput.html

http://www.tutorialspoint.com/python/python_files_io.htm

Data strutures

Dictionaries


Lists


Tuples:


Applications

http://www.black-glass.com/

Hidden Markov MOdels. http://www.black-glass.com/?p=299

Monte Carlo simulations: http://www.black-glass.com/?p=404

Modules and libraries

TkInter GUI: http://wiki.python.org/moin/TkInter

NumPy & SciPy

SciPy is a packafe for scientific computing which depends on the NumPy package.

http://www.scipy.org/Topical_Software

SciPy: www.scipy.org/SciPy

Documentation: http://docs.scipy.org/doc/

http://www.scipy.org/more_about_SciPy

Projects using NumPy and/or SciPy: http://www.scipy.org/Projects

http://www.scipy.org/NumPy_for_Matlab_Users

http://scipy-central.org/

NumPy & SciPy FAQ: http://www.scipy.org/FAQ

Biology & Bioinformatics

Biopython:http://biopython.org/wiki/Main_Page

Cock PJ, Antao T, Chang JT, Chapman BA, Cox CJ, et al. (2009) Biopython: freely available Python tools for computational molecular biology and bioinformatics. Bioinformatics 25: 1422–1423.


Biopython tutorial: http://biopython.org/DIST/docs/tutorial/Tutorial.html

Other

PyPI - Python package index: https://pypi.python.org/pypi

Python.org - useful modules: http://wiki.python.org/moin/UsefulModules

http://code.google.com/p/pythonxy/

http://matplotlib.org/

PyDoc: http://docs.python.org/2/library/pydoc


PyLab is part of matplotlib: http://stackoverflow.com/questions/12987624/confusion-between-numpy-scipy-matplotlib-and-pylab

iPython Notebook viewer: http://nbviewer.ipython.org/

Development environments

http://code.google.com/p/spyderlib/

http://ipython.org/

To launch iPython Notebook, write "ipython notebook" at the Windows command line (cmd.exe).

Distributions

EPD free edition: http://www.enthought.com/products/epd_free.php

Includes Python, iPython, IDLE, matplotlib, numpy and SciPy.

WinPython: https://code.google.com/p/winpython/

Includes NumPy, SciPy, matplotlib and Spyder.

Functions/methods

String methods:

string.split("delimiter"): Splits a string into a list of strings. Ex: sequenc = ATGCA seq = sequence.split("G") --> seq = ['AT', 'CA']

string.find() :


string.strip([chars]): "Return a copy of the string with the leading and trailing characters removed." Character to be removed are specified by [chars]. If no argument given, the chars argument defaults to removing whitespace.

Array/list methods:

list.append(x): Append object x to the end of list.

list.reverse(): Reverse order of elements in a list.

range / xrange(start, stop[,step]): returns a list of plain integers [start, start + step, start + 2 * step, ...]

"".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:

map(function,iterable): Apply function to every item in iterable and return the result.


Anonymous functions/lambda functions:

http://www.secnetix.de/olli/Python/lambda_functions.hawk

filter(function, iterable): Constructs a list from those elements of iterable for which the condition in function evaluates to true.


sum(): From official Python documentation: "Sums start and the items of an iterable from left to right and returns the total. Start defaults to 0"

Input/Output (I/O):


From http://www.python.org/dev/peps/pep-0234/ :

" Because the file iterator uses an internal buffer, mixing this

   with other file operations (e.g. file.readline()) doesn't work
   right:


Fore more on iteration over files, see:

http://www.bogotobogo.com/python/python_iterators.php

Class-related functions:

isinstance.

Keywords and statements

in :

with ... as


Indentation

http://stackoverflow.com/questions/119562/tabs-versus-spaces-in-python-programming

http://www.secnetix.de/olli/Python/block_indentation.hawk

http://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation

http://stackoverflow.com/questions/1024435/howto-fix-python-indentation

Classes

http://www.w3resource.com/python/python-object-classes.php

http://en.wikibooks.org/wiki/Python_Programming/Classes

A simple class inheritance example: http://www.daniweb.com/software-development/python/code/216596/a-simple-class-inheritance-example-python


An introduction to classes and inheritance in Python: http://www.jesshamrick.com/2011/05/18/an-introduction-to-classes-and-inheritance-in-python/

http://en.wikibooks.org/wiki/Think_Python/Inheritance

Inheritance in Python: http://www.packtpub.com/article/inheritance-python


Class scope:

http://www.codecademy.com/courses/python-intermediate-en-WL8e4/1/2#

Super:

Things to know about Python Super: http://www.artima.com/weblogs/viewpost.jsp?thread=236275


Method Resolution Order:

http://www.cafepy.com/article/python_attributes_and_methods/ch02.html

http://python-history.blogspot.no/2010/06/method-resolution-order.html


http://luisartola.com/software/2010/method-resolution-order-blues/

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]

Perl

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

http://www.cpan.org/

http://en.wikipedia.org/wiki/Outline_of_Perl

http://www.perl.org/


A "hash" in perl is the equivalent of a "dictionary" in Python.


BioPerl: http://www.bioperl.org/wiki/Main_Page

Books

http://shop.oreilly.com/product/9780596000806.do


Misc

A Quick Guide for Developing Effective Bioinformatics Programming Skills: http://www.ploscompbiol.org/article/info%3Adoi%2F10.1371%2Fjournal.pcbi.1000589