Commit aa9fde8c authored by Andrea Pierleoni's avatar Andrea Pierleoni
Browse files

updated license and bugfix

parent 16be1073
BioGraPy License Agreement
Permission to use, copy, modify, and distribute this software and its
documentation with or without modifications and for any purpose and
without fee is hereby granted, provided that any copyright notices
appear in all copies and that both those copyright notices and this
permission notice appear in supporting documentation, and that the
names of the contributors or copyright holders not be used in
advertising or publicity pertaining to distribution of the software
without specific prior permission.
THE CONTRIBUTORS AND COPYRIGHT HOLDERS OF THIS SOFTWARE DISCLAIM ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.
\ No newline at end of file
from drawer import Panel
from seqrecord import SeqRecordDrawer, SliceSeqRec
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import unittest
import doctest
def test_suite():
return unittest.TestSuite([
doctest.DocFileSuite('README.txt', package='biograpy'),
])
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
import unittest
import tempfile
import Image
from biograpy import Panel, tracks, features
class TestDrawer(unittest.TestCase):
def test_simple_features(self):
panel=Panel(fig_width=1000)#initialize a drawer
test_track = tracks.BaseTrack(features.Simple(name='feat1',start=100,end=756,),
features.Simple(name='feat2',start=300,end=1056,),
features.Simple(name='feat3',start=600,end=1356,),
features.Simple(name='feat4',start=800,end=1356,),
features.Simple(name='feat5',start= 1357,end=1806,),
name = 'test')
panel.add_track(test_track)
fh = tempfile.TemporaryFile()
panel.save(fh, format='png')
fh.seek(0)
img = Image.open(fh)
#self.assertEqual(img.size, (1000, 220))
self.assertEqual(img.format, 'PNG')
def test_suite():
return unittest.makeSuite(TestDrawer)
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
from Bio import SeqIO
import urllib
def test_uniprot():
from biograpy.seqrecord import SeqRecordDrawer
test_entry = 'S4A7_HUMAN'
seqrec = SeqIO.read(urllib.urlopen('http://www.ebi.ac.uk/Tools/webservices/rest/dbfetch/uniprotkb/%s/uniprotxml'%test_entry), 'uniprot')
handler = SeqRecordDrawer(seqrec, fig_width=1000)
fh = tempfile.TemporaryFile()
handler.save(fh + '.png')
fh.seek(0)
img = Image.open(fh)
self.assertEqual(img.format, 'PNG')
if __name__ == '__main__':
test_uniprot()
\ No newline at end of file
import unittest
import os
import tempfile
import Image
from Bio import SeqIO
from biograpy import Panel, tracks, features, seqrecord
class TestSeqrecord(unittest.TestCase):
def setUp(self):
self.emblpath = os.path.sep.join([os.path.dirname(__file__), "factor7.embl"])
self.seqr=SeqIO.parse(open(self.emblpath), 'embl').next()
def test_embl(self):
handler = seqrecord.SeqRecordDrawer(self.seqr, fig_width=1000)
(fhandle, fname) = tempfile.mkstemp(suffix='.png')
os.close(fhandle)
handler.save(fname)
img = Image.open(fname)
self.assertEqual(img.size, (1250, 587))
self.assertEqual(img.format, 'PNG')
os.unlink(fname)
def test_embl_500x500(self):
handler = seqrecord.SeqRecordDrawer(self.seqr, fig_width=500, fig_height=500)
(fhandle, fname) = tempfile.mkstemp(suffix='.png')
os.close(fhandle)
handler.save(fname)
img = Image.open(fname)
self.assertEqual(img.size, (625, 625))
self.assertEqual(img.format, 'PNG')
os.unlink(fname)
def test_patches(self):
# TODO: test
pass
def test_keeporder(self):
# TODO: test
pass
def test_suite():
return unittest.makeSuite(TestSeqrecord)
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
import unittest
import os
import tempfile
import Image
from Bio import SeqIO
from plone4bio.graphics import Panel
from plone4bio.graphics import features
# inspired by BioPerl Tutorial from http://bioperl.org/wiki/HOWTO:Graphics
class TestTutorial(unittest.TestCase):
def setUp(self):
# hit score start end
self.data1 = [
('hsHOX3', '381', 2, 200),
('scHOX3', '210', 2, 210),
('xlHOX3', '800', 2, 200),
('hsHOX2', '1000', 380, 921),
('scHOX2', '812', 402, 972),
('xlHOX2', '1200', 400, 970),
('BUM', '400', 300, 620),
('PRES1', '127', 310, 700),
]
def test_example1(self):
"""
# This is code example 1 in the Graphics-HOWTO
use strict;
use Bio::Graphics;
use Bio::SeqFeature::Generic;
my $panel = Bio::Graphics::Panel->new(-length => 1000, -width => 800);
my $track = $panel->add_track(-glyph => 'generic', -label => 1);
while (<>) { # read blast file
chomp;
next if /^\#/; # ignore comments
my($name,$score,$start,$end) = split /\t+/;
my $feature = Bio::SeqFeature::Generic->new(
-display_name => $name,
-score => $score,
-start => $start,
-end => $end
);
$track->add_feature($feature);
}
print $panel->png;
"""
# TODO: drawer vs. panel+track
panel = Panel(xmin = 1, xmax = 1000)
for data in self.data1:
feature = features.Simple(name=data[0], score=data[1], start=data[2], end=data[3])
panel.add_feature(feature)
fh = tempfile.TemporaryFile()
panel.save(fh, format='png')
fh.seek(0)
img = Image.open(fh)
#self.assertEqual(img.size, (1000, 300))
self.assertEqual(img.format, 'PNG')
# panel.save('/tmp/xxx.png')
# os.system('firefox /tmp/xxx.png')
# TODO: implements pad_left/right
def test_example2(self):
"""
Example 2. Rendering the blast hit file with scores and scale
#!/usr/bin/perl
# This is code example 2 in the Graphics-HOWTO
use strict;
use lib '/home/lstein/projects/bioperl-live';
use Bio::Graphics;
use Bio::SeqFeature::Generic;
my $panel = Bio::Graphics::Panel->new(
-length => 1000,
-width => 800,
-pad_left => 10,
-pad_right => 10,
);
my $full_length = Bio::SeqFeature::Generic->new(
-start => 1,
-end => 1000,
);
$panel->add_track($full_length,
-glyph => 'arrow',
-tick => 2,
-fgcolor => 'black',
-double => 1,
);
my $track = $panel->add_track(
-glyph => 'graded_segments',
-label => 1,
-bgcolor => 'blue',
-min_score => 0,
-max_score => 1000,
);
while (<>) { # read blast file
chomp;
next if /^\#/; # ignore comments
my($name,$score,$start,$end) = split /\t+/;
my $feature = Bio::SeqFeature::Generic->new(
-display_name => $name,
-score => $score,
-start => $start,
-end => $end
);
$track->add_feature($feature);
}
print $panel->png;
"""
# TODO
pass
def test_suite():
return unittest.makeSuite(TestTutorial)
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
This diff is collapsed.
Metadata-Version: 1.0
Name: biograpy
Version: 1.0bdev
Summary: UNKNOWN
Home-page: UNKNOWN
Author: Andrea Pierleoni
Author-email: apierleoni.dev@gmail.com
License: LGPL
Description: BioGraPy - Biological Graphical Library in Python
=================================================
Quick examples
------------------------------------------
Simple test
>>> from biograpy import Panel, tracks, features
>>> panel=Panel(fig_width=1000,fig_dpi=100)#initialize a drawer
>>> test_track = tracks.BaseTrack(name = 'test')
Create 5 graphicfeatures
>>> feat1=features.Simple(name='feat1',start=100,end=756,fc='r',aplha=0.5,height=1)
>>> feat2=features.Simple(name='feat2',start=300,end=1056,fc='pink',aplha=0.5,height=1)
>>> feat3=features.Simple(name='feat3',start=600,end=1356,fc='y',aplha=0.5,height=1)
>>> feat4=features.Simple(name='feat4',start=800,end=1356,fc='g',aplha=0.5,height=1)
>>> feat5=features.Simple(name='feat5',start= 1357,end=1806,fc='b',aplha=0.5,height=1)
Add the features to the track::
>>> test_track.append(feat1)
>>> test_track.append(feat2)
>>> test_track.append(feat3)
>>> test_track.append(feat4)
>>> test_track.append(feat5)
Add the track to the panel::
>>> panel.add_track(test_track)
Save the drawn image in PDF format::
>>> panel.save('test.pdf')
or in short, using default styles, and saving as PNG::
>>> from biograpy import Panel, tracks, features
>>> panel=Panel(fig_width=1000)#initialize a drawer
>>> test_track = tracks.BaseTrack(features.Simple(name='feat1',start=100,end=756,),
features.Simple(name='feat2',start=300,end=1056,),
features.Simple(name='feat3',start=600,end=1356,),
features.Simple(name='feat4',start=800,end=1356,),
features.Simple(name='feat5',start= 1357,end=1806,),
name = 'test')
>>> panel.add_track(test_track)
>>> panel.save('test.png')
draw a SeqRecord
>>> from biograpy.seqrecord import SeqRecordDrawer
>>> from Bio import SeqIO
>>> seqrec = SeqIO.read(open('biograpy/tests/test_uniprot.xml'),'uniprot-xml')
>>> grseqrec = SeqRecordDrawer(seqrec)
>>> grseqrec.save('biograpy/tests/test_uniprot.svg')
.. _history:
Changelog
=========
1.0 beta
---------------------
- Completed API documentation.
- Bug fix
1.0 alpha
---------------------
Major revision
- Added novel feature type: PlotFeature, BarPlotFeature
TextSequence
- Added colorbars
- Can now use sequence as X tick labels
- Improved track and figure positioning
- Added per-letter annotation support
- Added url in SVG as alternative to
HTML maps
- Added legend for tracks
- Many bug fix and minor improvements
0.3 (released)
---------------------
- changed namespace to biograpy
- Public release
0.2 (unreleased)
---------------------
- boxes and imagemap [mauro]
0.1 (unreleased)
---------------------
- Initial draft
.. _authors:
=======
AUTHORS
=======
* Andrea Pierleoni
============
CONTRIBUTORS
============
* Mauro Amico
Platform: UNKNOWN
Classifier: Programming Language :: Python
README.txt
setup.cfg
setup.py
src/biograpy/__init__.py
src/biograpy/drawer.py
src/biograpy/features.py
src/biograpy/seqrecord.py
src/biograpy/tracks.py
src/biograpy.egg-info/PKG-INFO
src/biograpy.egg-info/SOURCES.txt
src/biograpy.egg-info/dependency_links.txt
src/biograpy.egg-info/entry_points.txt
src/biograpy.egg-info/namespace_packages.txt
src/biograpy.egg-info/not-zip-safe
src/biograpy.egg-info/requires.txt
src/biograpy.egg-info/top_level.txt
src/biograpy/tests/__init__.py
src/biograpy/tests/test_doctest.py
src/biograpy/tests/test_drawer.py
src/biograpy/tests/test_remote_dbfetch.py
src/biograpy/tests/test_seqrecord.py
src/biograpy/tests/test_tutorial.py
\ No newline at end of file
# -*- Entry points: -*-
\ No newline at end of file
setuptools
biopython
matplotlib>=1.0
numpy>=1.1
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment