bein copyright © software carpentry 2011 this work is licensed under the creative commons...

19
Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution Lice See http://software-carpentry.org/license.html for more informati Data Management

Upload: trevor-palmer

Post on 17-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Bein

Copyright © Software Carpentry 2011

This work is licensed under the Creative Commons Attribution License

See http://software-carpentry.org/license.html for more information.

Data Management

Page 2: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

1. Simplify calling external programs in

your calculations

Page 3: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

1. Simplify calling external programs in

your calculations

2. Track the external progams you run

and files to preserve

Page 4: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

1. Simplify calling external programs in

your calculations

2. Track the external progams you run

and files to preserve

3. Minimize the distance between prototype

and production code

Page 5: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

Bein

MiniLIMS

execution blocks

program

bindings

Page 6: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

MiniLIMS

SQLite database

Directory for files

.../

boris

boris.files/

...

Page 7: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

MiniLIMS

#!/usr/bin/env python

from bein import *

M = MiniLIMS("/path/to/sqlitedb")

Bein creates the databaseif it does not exist

Page 8: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

Execution Blocks

M = MiniLIMS("/path/to/sqlitedb")

with execution(M) as ex:

...

...

more_stuff()

Creates a working directory

Working directory cleaned up anddeleted here automatically

Page 9: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

Program Bindings@programdef count_lines(filename):

def parse_output(p): pat = r'^\s*(\d+)\s+' + filename + r'\s*$' m = re.search(pat, ''.join(p.stdout)) return int(m.groups()[-1])

return {"arguments": ["wc","-l",filename], "return_value": parse_output}

Page 10: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

Program Bindings@programdef count_lines(filename):

def parse_output(p): pat = r'^\s*(\d+)\s+' + filename + r'\s*$' m = re.search(pat, ''.join(p.stdout)) return int(m.groups()[-1])

return {"arguments": ["wc","-l",filename], "return_value": parse_output}

Transform it intoa program binding

Page 11: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

Program Bindings@programdef count_lines(filename):

def parse_output(p): pat = r'^\s*(\d+)\s+' + filename + r'\s*$' m = re.search(pat, ''.join(p.stdout)) return int(m.groups()[-1])

return {"arguments": ["wc","-l",filename], "return_value": parse_output}

Return arguments anda function to extracta return value

Page 12: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

Program Bindingswith execution() as ex:

n = count_lines(ex, filename)

n = count_lines(ex, filename, stderr=“asdf”)

f = count_lines.nonblocking(ex, filename)

n = f.wait()

f = count_lines.nonblocking(ex, filename,

via=“lsf”)

n = f.wait()

Page 13: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

#!/usr/bin/env python

import sys

a = f()

for i in range(5):

...

Page 14: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

#!/usr/bin/env python

import sys

from bein import *

a = f()

for i in range(5):

...

Page 15: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

#!/usr/bin/env python

import sys

from bein import *

with execution() as ex:

a = f()

for i in range(5):

...

Page 16: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

#!/usr/bin/env python

import sys

from bein import *

M = MiniLIMS("/path/to/sqlitedb")

with execution(M) as ex:

a = f()

for i in range(5):

...

Page 17: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

pip install bein

Documentation at:

http://madhadron.com/bein/

Page 18: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

Data Management Bein

Bein

MiniLIMS

execution blocks

program

bindings

Page 19: Bein Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See

March 2011

created by

Frederick Ross

Copyright © Software Carpentry 2011

This work is licensed under the Creative Commons Attribution License

See http://software-carpentry.org/license.html for more information.