This notebook is part of a tutorial series for the FRETBursts burst analysis software.
In this notebook we present two ways to load a file in FRETBursts. It all boils down to putting the full file name in a variable. We show one text based and one GUI based example.
We start loading the FRETBursts
software:
from fretbursts import *
- Optimized (cython) burst search loaded. - Optimized (cython) photon counting loaded. ------------------------------------------------------------- You are running FRETBursts (version 0.4rc4-20-g4ea8dd4). If you use this software in a publication, please cite it as: FRETBursts - An opensource single-molecule FRET burst analysis toolkit. A. Ingargiola 2014. https://github.com/tritemio/FRETBursts -------------------------------------------------------------
# This enables the Qt GUI (for the open-file dialog)
%gui qt
# This enables inline plots
%matplotlib inline
The last line tells us which FRETBursts revision is currently in use. This information can be used for long-term reproducibility, a crucial problem in science. Moreover, knowing the revision allows to easily track software regressions.
Now we can select a data-file by pasting its name in a variable or by using a conventional GUI dialog. In either cases we'll end up with the a file-name stored in the variable full_fname
.
The full list of smFRET measurements used in the FRETBursts tutorials can be found on Figshare.
Here we download the us-ALEX data-file and put it in a folder named data
, inside the notebook folder.
For this purpose we use the download_file
function provided by FRETBursts:
url = 'http://files.figshare.com/1839121/0023uLRpitc_NTP_20dT_0.5GndCl.hdf5'
download_file(url, save_dir='./data')
URL: http://files.figshare.com/1839121/0023uLRpitc_NTP_20dT_0.5GndCl.hdf5 File: 0023uLRpitc_NTP_20dT_0.5GndCl.hdf5 File already on disk: C:\Data\Antonio\software\src\fretbursts_notebooks\notebooks\data/0023uLRpitc_NTP_20dT_0.5GndCl.hdf5 Delete it to re-download.
We can select a data file with an "Open File" windows like this:
To launch the dialog run this (note: it may pop-up in the foreground):
full_fname = gui_fname('./')
C:/Data/Antonio/software/src/fretbursts_notebooks/notebooks/data/0023uLRpitc_NTP_20dT_0.5GndCl.hdf5
Now full_fname
contains the path of the file you just selected. Run again the previous cell to select a new file.
Alternatively, we can directly define the file name to be loaded:
# That's an example dataset, download it from (link here)
file_name = "0023uLRpitc_NTP_20dT_0.5GndCl.hdf5"
# Here the folder is the subfolder "data" of current notebook folder
folder_name = './data/'
and concatenate the data folder with the file name:
full_fname = folder_name + file_name
full_fname
'./data/0023uLRpitc_NTP_20dT_0.5GndCl.hdf5'
Let's check that the file exists:
import os
if os.path.isfile(full_fname):
print "Perfect, I found the file!"
else:
print "Sorry, I can't find the file:\n", full_fname
Perfect, I found the file!
--nogui
" flag¶When using the GUI dialog the ipython notebook have to be properly initialialized to handle both an external QT GUI and inline plots. This is automatically done by the load_fretbursts
script by default. One current drawback is that when this initialization is performed, the notebook can't be run in batch (Cell -> Run All) anymore. If you don't use the GUI Open-File dialog and want to run the notebook in one single step you can call load_fretbursts
with the --nogui
flag. Whit this flag you can still use %matplotlib qt
to have interctive plots in an external QT window.
Once we have the filename in a variable the data can be loaded with:
d = loader.hdf5(full_fname)
from IPython.core.display import HTML
HTML(open("./styles/custom2.css", "r").read())