-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from andrewjpage/reference_genome_file
Reference genome file
- Loading branch information
Showing
13 changed files
with
140 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.0.0 | ||
2.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import matplotlib.pyplot as plt | ||
|
||
class PlotProfile: | ||
|
||
def __init__(self, fragments, output_file): | ||
self.fragments = fragments | ||
self.output_file = output_file | ||
|
||
def total_bases(self): | ||
return sum([f.num_bases() for f in self.fragments]) | ||
|
||
# make this look pretty | ||
def create_plot(self): | ||
names = [str(f.number) for f in self.fragments] | ||
size = [int(f.num_bases()) for f in self.fragments] | ||
reversed_fragments = [f.reversed_frag for f in self.fragments] | ||
dna_A = [f.dna_A for f in self.fragments] | ||
|
||
for i in range(len(names)): | ||
if dna_A[i]: | ||
names[i] += " - Ori" | ||
|
||
my_circle=plt.Circle( (0,0), 0.7, color='white') | ||
|
||
piechart = plt.pie(size, labels=names, wedgeprops = { 'linewidth' : 7, 'edgecolor' : 'white' }) | ||
|
||
# set hatching pattern | ||
for i in range(len(piechart[0])): | ||
if reversed_fragments[i]: | ||
piechart[0][i].set_hatch('+') | ||
p=plt.gcf() | ||
p.gca().add_artist(my_circle) | ||
plt.savefig( self.output_file ) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import unittest | ||
import os | ||
import shutil | ||
import filecmp | ||
from socru.PlotProfile import PlotProfile | ||
from socru.Fragment import Fragment | ||
|
||
test_modules_dir = os.path.dirname(os.path.realpath(__file__)) | ||
data_dir = os.path.join(test_modules_dir, 'data','plot_profile') | ||
|
||
class TestPlotProfile(unittest.TestCase): | ||
|
||
def test_plot_profile(self): | ||
fragments = [] | ||
fragments.append(Fragment([], sequence = "AAAA", number = 1, reversed_frag = False, dna_A = False)) | ||
fragments.append(Fragment([], sequence = "AAA", number = 3, reversed_frag = False, dna_A = False)) | ||
fragments.append(Fragment([], sequence = "AAAAAAAAAA", number = 2, reversed_frag = False, dna_A = True)) | ||
fragments.append(Fragment([], sequence = "A", number = 4, reversed_frag = False, dna_A = False)) | ||
|
||
p = PlotProfile(fragments, 'plot.pdf') | ||
p.create_plot() | ||
self.assertTrue(os.path.exists('plot.pdf')) | ||
os.remove('plot.pdf') | ||
|
||
def test_plot_profile_some_reversed(self): | ||
fragments = [] | ||
fragments.append(Fragment([], sequence = "AAAA", number = 1, reversed_frag = True, dna_A = True)) | ||
fragments.append(Fragment([], sequence = "AAA", number = 3, reversed_frag = False, dna_A = False)) | ||
fragments.append(Fragment([], sequence = "AAAAAAAAAA", number = 2, reversed_frag = True, dna_A = False)) | ||
fragments.append(Fragment([], sequence = "A", number = 4, reversed_frag = False, dna_A = False)) | ||
|
||
p = PlotProfile(fragments, 'plot2.pdf') | ||
p.create_plot() | ||
|
||
self.assertTrue(os.path.exists('plot2.pdf')) | ||
os.remove('plot2.pdf') | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters