예제 #1
0
 def test_randomization(self):
     com = Community(sample_abundance)       
     com.fit_model('etienne')                
     etienne_model = com.get_model('etienne')
     self.assertEqual(sum(etienne_model.random_community()), com.J)
     self.assertEqual(sum(etienne_model.random_community(2500)), 2500)
     
예제 #2
0
 def test_optimization(self):
     com = Community(sample_abundance)
     com.fit_model('lognormal')
     model = com.get_model('lognormal')
     print '* fitted to lognormal model:'
     print model
     self.assertEqual(round(2.14539 , 5), round(model.mu, 5))
     self.assertEqual(round(1.28561 , 5), round(model.sd  , 5))
예제 #3
0
 def test_optimization(self):
     com = Community(sample_abundance)
     com.fit_model('etienne')
     etienne_model = com.get_model('etienne')
     print '* fitted to etienne model:'
     print etienne_model
     self.assertEqual(round(66.1478972798     , 5), round(etienne_model.theta, 5))
     self.assertEqual(round(98.171564034001662, 5), round(etienne_model.lnL  , 5))
     self.assertEqual(round(134.10853894914644, 2), round(etienne_model.I    , 2))
예제 #4
0
 def test_optimization(self):
     com = Community(sample_abundance)
     com.fit_model('ewens')
     ewens_model = com.get_model('ewens')
     print '* fitted to ewens model:'
     print ewens_model
     self.assertEqual(round(29.257363187464055, 4), round(ewens_model.theta, 4))
     self.assertEqual(round(107.69183285311374, 4), round(ewens_model.lnL, 4))
     self.assertEqual(14.720795937459272, ewens_model.I)
예제 #5
0
def main():
    """
    main function
    kind = 'short'
    infile = 'bci_short.txt'
    """
    try:
        kind = argv[1]
    except IndexError:
        kind = None
    
    kinds = ['short', 'full']
    if not kind in kinds or not kind:
        exit('\nERROR: kind should be one of:%s\n' % \
             ((' "%s"' * len (kinds)) % tuple (kinds)))

    if kind == 'short':
        # reload abundance with shorter dataset
        abd = Community ('../dataset_trial/bci_short.txt')
    elif kind == 'full':
        abd = Community ('../dataset_trial/bci_full.txt')
    else:
        exit()
    test_failed = []
    abd.fit_model(name='etienne')
    abd.fit_model(name='ewens')
예제 #6
0
import matplotlib  # These two lines is because you're in a cluster
matplotlib.use('Agg')  # and there may be no "X".
from ecolopy_dev import Community
from ecolopy_dev.utils import draw_shannon_distrib

com = Community('Fulcaldea_stuessyi_log_abund.txt')
print com

com.fit_model('ewens')
com.set_current_model('ewens')
ewens_model = com.get_model('ewens')
print ewens_model

com.fit_model('lognormal')
com.set_current_model('lognormal')
lognormal_model = com.get_model('lognormal')
print lognormal_model

com.fit_model('etienne')
com.set_current_model('etienne')
etienne_model = com.get_model('etienne')
print etienne_model

tmp = {}
for met in ['fmin', 'slsqp', 'l_bfgs_b', 'tnc']:
    print 'Optimizing with %s...' % met
    try:
        com.fit_model(name='etienne', method=met, verbose=False)
        model = com.get_model('etienne')
        tmp[met] = {}
        tmp[met]['model'] = model
예제 #7
0
파일: test.py 프로젝트: fransua/ecolopy
import matplotlib
matplotlib.use('Agg')

from ecolopy_dev import Community
from ecolopy_dev.utils import draw_shannon_distrib

abd = Community('dataset_trial/bci_short.txt')
abd.fit_model('etienne')
abd.set_current_model('etienne')
pval, neut_h = abd.test_neutrality (model='etienne',
                                    gens=1000, full=True)
draw_shannon_distrib(neut_h, abd.shannon, outfile='lala.png')



abd2 = Community('test2.txt')
abd2.fit_model('lognormal')
abd2.set_current_model('lognormal')
pval, neut_h = abd2.test_neutrality (model='lognormal',
                                     gens=1000, full=True)
draw_shannon_distrib(neut_h,abd2.shannon)


bci = Community('../dataset_trial/bci_full.txt')
bci.fit_model('lognormal')
bci.set_current_model('lognormal')

pval, bci_neut_h = bci.test_neutrality (model='lognormal',
                                        gens=1000, full=True)

예제 #8
0
import matplotlib     # These two lines is because you're in a cluster
matplotlib.use('Agg') # and there may be no "X".
from ecolopy_dev import Community
from ecolopy_dev.utils import draw_shannon_distrib

com = Community('Fulcaldea_stuessyi_1kfrac.txt')
print com

com.fit_model('ewens')
com.set_current_model('ewens')
ewens_model = com.get_model('ewens')
print ewens_model

com.fit_model('lognormal')
com.set_current_model('lognormal')
lognormal_model = com.get_model('lognormal')
print lognormal_model

com.fit_model('etienne')
com.set_current_model('etienne')
etienne_model = com.get_model('etienne')
print etienne_model

tmp = {}
for met in ['fmin', 'slsqp', 'l_bfgs_b', 'tnc']:
    print 'Optimizing with %s...' % met
    try:
        com.fit_model(name='etienne', method=met, verbose=False)
        model = com.get_model('etienne')
        tmp[met] ={}
        tmp[met]['model'] = model
예제 #9
0
import matplotlib
matplotlib.use('Agg')
from ecolopy_dev import Community
from ecolopy_dev.utils import draw_shannon_distrib

##test_abund.txt would be the genome abundance / the diploid number of chromosomes
## j_tot is obtained by taking the total number of individuals
com = Community('test_log_abund.txt', j_tot=2150924886)
print com

com.fit_model('ewens')
com.set_current_model('ewens')
ewens_model = com.get_model('ewens')
print ewens_model

com.fit_model('lognormal')
com.set_current_model('lognormal')
lognormal_model = com.get_model('lognormal')
print lognormal_model

com.fit_model('etienne')
com.set_current_model('etienne')
etienne_model = com.get_model('etienne')
print etienne_model

tmp = {}
likelihoods = []
for met in ['fmin', 'slsqp', 'l_bfgs_b', 'tnc']:
    print 'Optimizing with %s...' % met
    try:
        com.fit_model(name='etienne', method=met, verbose=False)
예제 #10
0
파일: ecolopy.py 프로젝트: sestaton/sesbio
import matplotlib     
matplotlib.use('Agg') 
from ecolopy_dev import Community
from ecolopy_dev.utils import draw_shannon_distrib

##test_abund.txt would be the genome abundance / the diploid number of chromosomes
## j_tot is obtained by taking the total number of individuals
com = Community('test_log_abund.txt', j_tot=2150924886)
print com

com.fit_model('ewens')
com.set_current_model('ewens')
ewens_model = com.get_model('ewens')
print ewens_model

com.fit_model('lognormal')
com.set_current_model('lognormal')
lognormal_model = com.get_model('lognormal')
print lognormal_model

com.fit_model('etienne')
com.set_current_model('etienne')
etienne_model = com.get_model('etienne')
print etienne_model

tmp = {}
likelihoods = []
for met in ['fmin', 'slsqp', 'l_bfgs_b', 'tnc']:
    print 'Optimizing with %s...' % met
    try:
        com.fit_model(name='etienne', method=met, verbose=False)
예제 #11
0
 def test_randomization(self):
     com = Community(sample_abundance)       
     com.fit_model('lognormal')                
     model = com.get_model('lognormal')
     self.assertTrue(sum(model.random_community())>1000)
... type 'enter' to continue
"""

raw_input()

print """
In the next step we are going to create an object 'Community' that will
represent the distribution of abundance of the well known/studied BCI dataset.

We are going to load this object under the name 'com':

>>> com = Community ('bci_full.txt')

"""

com = Community ('dataset_trial/bci_short.txt')

print """
In order to see quickly how does this abundance looks like, we can use the print
command:

>>> print com
  
"""

print com

print """
... type 'enter' to continue
"""
raw_input()