Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
src/test.py
src/biograpy/tests/*.png
src/biograpy/tests/*.svg
src/biograpy/tests/*.pdf
src/biograpy/tests/*.jpg
tests/*.png
tests/*.svg
tests/*.pdf
tests/*.jpg
.DS_Store
114 changes: 114 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
BioGraPy - Biological Graphical Library in Python
=================================================

Fork that adds support to plot the tracks below an existing figure, and adds some new features to draw such as text sequence with automatic font size and highlighted text.

```python
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import numpy as np

import biograpy
from Bio.SeqFeature import SeqFeature, FeatureLocation
from Bio.Seq import Seq


fig1, ax = plt.subplots(figsize=(10,3), dpi=300)

ax.scatter(x=list(range(0, 1200)), y=np.random.random(1200))
ax.set_xlim([0,1200])
ax.set_ylim([0,2])

# We use the package biograpy to create Panel, tracks, and features
panel = biograpy.Panel(fig1)
track = biograpy.tracks.BaseTrack()

# Simple feature drawn as a rectangle
track.add_feature(biograpy.features.Simple(name='Simple1', start = 50, end = 300))

# Gene feature drawn as an arrow
genefeat = SeqFeature(FeatureLocation(100,500), type='gene', strand=1)
track.add_feature(biograpy.features.GeneSeqFeature(genefeat, name='GeneSeqFeature1'))

# Simple feature with color
track.add_feature(biograpy.features.Simple(name='Simple_colored1', start = 500, end = 820, color_by_cm=False, fc='r'))

# Gene feature with color
track.add_feature(biograpy.features.GeneSeqFeature(genefeat,name='GeneSeqFeature2_colored',fc='r'))

# Very short gene feature (to test the arrow head automatic sizing)
genefeat = SeqFeature(FeatureLocation(800,810), type='gene', strand=1)
track.add_feature(biograpy.features.GeneSeqFeature(genefeat, name='GeneSeqFeature_very_short'))

# mRNA with one CDS drawn as a shaded rectangle with an arrow on top
CDS_feature = SeqFeature(FeatureLocation(180,1000), type='CDS', strand=-1)
mRNA_feature = SeqFeature(FeatureLocation(180,1100), type='mRNA', strand=-1)
mRNAandCDSfeat = biograpy.features.CoupledmRNAandCDS(mRNA_feature, CDS_feature,
name='CoupledmRNAandCDS1_strandm', ec='k')
track.add_feature(mRNAandCDSfeat)

# mRNA with CDS, custom color
CDS_feature = SeqFeature( FeatureLocation(200,600), type='CDS', strand=1)
mRNA_feature = SeqFeature( FeatureLocation(100,800), type='mRNA', strand=1)
mRNAandCDSfeat = biograpy.features.CoupledmRNAandCDS(mRNA_feature, CDS_feature,
name='CoupledmRNAandCDS1_strandp_colored', ec='r', fc='r')
track.add_feature(mRNAandCDSfeat)

# Very short mRNA with CDS (to test the arrow head automatic sizing)
CDS_feature = SeqFeature( FeatureLocation(250,260), type='CDS', strand=1)
mRNA_feature = SeqFeature( FeatureLocation(220,300), type='mRNA', strand=1)
mRNAandCDSfeat = biograpy.features.CoupledmRNAandCDS(mRNA_feature, CDS_feature,
name='CoupledmRNAandCDS1_very_short')
track.add_feature(mRNAandCDSfeat)

# Gene feature on minus strand
geneSeqfeat = SeqFeature( FeatureLocation(900,200), type = 'gene', strand=-1)
genefeat = biograpy.features.GeneSeqFeature(geneSeqfeat, name='GeneSeqFeature3_strandm')
track.add_feature(genefeat)

track2 = biograpy.tracks.BaseTrack(biograpy.features.Simple(name='Simple3_track2', start= 0, end = 80))

panel.add_track(track)
panel.add_track(track2)
panel._draw_tracks()
panel.save('biograpy_test1.png')
```

![example1](/examples/biograpy_test1.png)

```python
fig1, ax = plt.subplots(figsize=(11,3), dpi=400)

ax.scatter(x=list(range(0, 100)), y=np.random.random(100))
ax.set_xlim([0,100])
ax.set_ylim([0,2])

# Create panel and track
panel = biograpy.Panel(fig1)
track = biograpy.tracks.BaseTrack()

# Text sequence feature
track.add_feature(biograpy.features.TextSequence(
'MKKVIVIGVNHAGTSFIRTLLSKSKDFQVNAYDRNTNISFLGCGIALAVSGVVKNTEDLFYSTPEELKAMGANVFMAHDVVGLDLDKKQVIVKDL',
start=10, name="TextSequence1"))

"""
Pretty text sequence feature allows to pass a text sequence together with a list of regions
to highlight. The font size is calculated automatically to fit the scale of the x axis.
"""

prettyTextFeat = biograpy.features.PrettyTextSequence(
'KSKDFQVNAYDRNMKKVIVIGVNHAGTSFIRTLLSKSKDFQVNAYDRNTNISFLGCGIALAVSGVVKNTEDLFYSTPEELKAMGANVFMAHDVVGLDLDKKQVIVKDLATGKETVDHY',
highlightList=[{'start':0, 'end':10, 'background_color':'red', 'background_color_alpha':0.4, 'weight':900},
{'start':20, 'end':25, 'foreground_color':'blue', 'weight':100}
],
start=20, name='PrettyTextSequence1')
track.add_feature(prettyTextFeat)

panel.add_track(track)
panel.save('biograpy_test2.png')
panel._draw_tracks()
```

![example1](/examples/biograpy_test2.png)
61 changes: 0 additions & 61 deletions README.txt

This file was deleted.

1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
187 changes: 187 additions & 0 deletions biograpy.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
Metadata-Version: 1.1
Name: biograpy
Version: 1.1.dev0
Summary: UNKNOWN
Home-page: UNKNOWN
Author: Andrea Pierleoni
Author-email: apierleoni.dev@gmail.com
License: LGPL
Description: BioGraPy - Biological Graphical Library in Python
=================================================

Fork that adds support to plot the tracks below an existing figure, and adds some new features to draw such as text sequence with automatic font size and highlighted text.

```python
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import numpy as np

import biograpy
from Bio.SeqFeature import SeqFeature, FeatureLocation
from Bio.Seq import Seq


fig1, ax = plt.subplots(figsize=(10,3), dpi=300)

ax.scatter(x=list(range(0, 1200)), y=np.random.random(1200))
ax.set_xlim([0,1200])
ax.set_ylim([0,2])

# We use the package biograpy to create Panel, tracks, and features
panel = biograpy.Panel(fig1)
track = biograpy.tracks.BaseTrack()

# Simple feature drawn as a rectangle
track.add_feature(biograpy.features.Simple(name='Simple1', start = 50, end = 300))

# Gene feature drawn as an arrow
genefeat = SeqFeature(FeatureLocation(100,500), type='gene', strand=1)
track.add_feature(biograpy.features.GeneSeqFeature(genefeat, name='GeneSeqFeature1'))

# Simple feature with color
track.add_feature(biograpy.features.Simple(name='Simple_colored1', start = 500, end = 820, color_by_cm=False, fc='r'))

# Gene feature with color
track.add_feature(biograpy.features.GeneSeqFeature(genefeat,name='GeneSeqFeature2_colored',fc='r'))

# Very short gene feature (to test the arrow head automatic sizing)
genefeat = SeqFeature(FeatureLocation(800,810), type='gene', strand=1)
track.add_feature(biograpy.features.GeneSeqFeature(genefeat, name='GeneSeqFeature_very_short'))

# mRNA with one CDS drawn as a shaded rectangle with an arrow on top
CDS_feature = SeqFeature(FeatureLocation(180,1000), type='CDS', strand=-1)
mRNA_feature = SeqFeature(FeatureLocation(180,1100), type='mRNA', strand=-1)
mRNAandCDSfeat = biograpy.features.CoupledmRNAandCDS(mRNA_feature, CDS_feature,
name='CoupledmRNAandCDS1_strandm', ec='k')
track.add_feature(mRNAandCDSfeat)

# mRNA with CDS, custom color
CDS_feature = SeqFeature( FeatureLocation(200,600), type='CDS', strand=1)
mRNA_feature = SeqFeature( FeatureLocation(100,800), type='mRNA', strand=1)
mRNAandCDSfeat = biograpy.features.CoupledmRNAandCDS(mRNA_feature, CDS_feature,
name='CoupledmRNAandCDS1_strandp_colored', ec='r', fc='r')
track.add_feature(mRNAandCDSfeat)

# Very short mRNA with CDS (to test the arrow head automatic sizing)
CDS_feature = SeqFeature( FeatureLocation(250,260), type='CDS', strand=1)
mRNA_feature = SeqFeature( FeatureLocation(220,300), type='mRNA', strand=1)
mRNAandCDSfeat = biograpy.features.CoupledmRNAandCDS(mRNA_feature, CDS_feature,
name='CoupledmRNAandCDS1_very_short')
track.add_feature(mRNAandCDSfeat)

# Gene feature on minus strand
geneSeqfeat = SeqFeature( FeatureLocation(900,200), type = 'gene', strand=-1)
genefeat = biograpy.features.GeneSeqFeature(geneSeqfeat, name='GeneSeqFeature3_strandm')
track.add_feature(genefeat)

track2 = biograpy.tracks.BaseTrack(biograpy.features.Simple(name='Simple3_track2', start= 0, end = 80))

panel.add_track(track)
panel.add_track(track2)
panel._draw_tracks()
panel.save('biograpy_test1.png')
```

![example1](/examples/biograpy_test1.png)

```python
fig1, ax = plt.subplots(figsize=(11,3), dpi=400)

ax.scatter(x=list(range(0, 100)), y=np.random.random(100))
ax.set_xlim([0,100])
ax.set_ylim([0,2])

# Create panel and track
panel = biograpy.Panel(fig1)
track = biograpy.tracks.BaseTrack()

# Text sequence feature
track.add_feature(biograpy.features.TextSequence(
'MKKVIVIGVNHAGTSFIRTLLSKSKDFQVNAYDRNTNISFLGCGIALAVSGVVKNTEDLFYSTPEELKAMGANVFMAHDVVGLDLDKKQVIVKDL',
start=10, name="TextSequence1"))

"""
Pretty text sequence feature allows to pass a text sequence together with a list of regions
to highlight. The font size is calculated automatically to fit the scale of the x axis.
"""

prettyTextFeat = biograpy.features.PrettyTextSequence(
'KSKDFQVNAYDRNMKKVIVIGVNHAGTSFIRTLLSKSKDFQVNAYDRNTNISFLGCGIALAVSGVVKNTEDLFYSTPEELKAMGANVFMAHDVVGLDLDKKQVIVKDLATGKETVDHY',
highlightList=[{'start':0, 'end':10, 'background_color':'red', 'background_color_alpha':0.4, 'weight':900},
{'start':20, 'end':25, 'foreground_color':'blue', 'weight':100}
],
start=20, name='PrettyTextSequence1')
track.add_feature(prettyTextFeat)

panel.add_track(track)
panel.save('biograpy_test2.png')
panel._draw_tracks()
```

![example1](/examples/biograpy_test2.png)
.. _history:

Changelog
=========

1.1 alpha
---------------------
- Added novel feature types: PrettyTextSequence, CoupledmRNAandCDS
- Added option of drawing the panel below an existing matplotlib figure

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
* Marc Weber
Platform: UNKNOWN
Classifier: Programming Language :: Python
16 changes: 16 additions & 0 deletions biograpy.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
README.md
setup.cfg
setup.py
biograpy/__init__.py
biograpy/drawer.py
biograpy/features.py
biograpy/seqrecord.py
biograpy/tracks.py
biograpy.egg-info/PKG-INFO
biograpy.egg-info/SOURCES.txt
biograpy.egg-info/dependency_links.txt
biograpy.egg-info/entry_points.txt
biograpy.egg-info/namespace_packages.txt
biograpy.egg-info/not-zip-safe
biograpy.egg-info/requires.txt
biograpy.egg-info/top_level.txt
1 change: 1 addition & 0 deletions biograpy.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading