<commit_before># -*- coding: utf-8 -*-
"""
Created on Thu Oct 10 14:34:07 2013
Updated march 25, 2014

@author: <NAME>

Supporting routines to help users easily 
pass Antimony models to roadRunner

"""

import matplotlib.pyplot as plt
import roadrunner
import libantimony
import tellurium

def teRoadRunner (modelName = ''):
    rr = roadrunner.RoadRunner(modelName)
    rr.conservedMoietyAnalysis = True
    return rr

#get version from VERSION file
def getTelluriumVersion():
    import os
    f = open(os.path.dirname(tellurium.__file__) +'\\VERSION.txt', 'r')
    ver = f.read().rstrip()
    f.close()
    return ver
    
# Save a string to a file
def saveToFile (fileName, str):
    """Save a string to a file. Takes two arguments, 
    the file name and the string to save:
    
    saveToFile ('c:\\myfile.txt', strVariable)"""
    outFile = open(fileName, 'w')
    outFile.write(str)
    outFile.close()
    
def readFromFile (fileName):
    """Load a file and return contents as a string, 

    str = readFromFile ('c:\\myfile.txt')"""
 
    file = open(fileName, 'r')
    return file.read()

def loadSBMLModel (sbml):
    rr = roadrunner.RoadRunner (sbml)
    rr.simulateOptions.structuredResult = False
    return rr
    
# Load an Antimony file   
def loadAntimonyModel (antStr):
    """Load an Antimony string:
    
    r = loadAntModel (antimonyStr)
    """
    err = libantimony.loadAntimonyString (antStr)
 
    if (err < 0):
       raise Exception('Antimony: ' + libantimony.getLastError())
       
    Id = libantimony.getMainModuleName()
    sbmlStr = libantimony.getSBMLString(Id)
    rr = roadrunner.RoadRunner()
    rr.simulateOptions.structuredResult = False
    rr.load(sbmlStr)
    return rr

def plotWithLegend (r, result):
    """
    Plot an array and include a legend. The first argument must be a roadrunner variable. 
    The second argument must be an array containing data to plot. The first column of the array will
    be the x-axis and remaining columns the y-axis. Returns
    a handle to the plotting object.
    
    plotWithLegend (r, result)
    """
    if not isinstance (r, roadrunner.RoadRunner):
        raise Exception ('First argument must be a roadrunner variable')<commit_msg>loadAntimonyModel now configures rr.conservedMoietyAnalysis = True<commit_after># -*- coding: utf-8 -*-
"""
Created on Thu Oct 10 14:34:07 2013
Updated march 25, 2014

@author: <NAME>

Supporting routines to help users easily 
pass Antimony models to roadRunner

"""

import matplotlib.pyplot as plt
import roadrunner
import libantimony
import tellurium

def teRoadRunner (modelName = ''):
    rr = roadrunner.RoadRunner(modelName)
    rr.conservedMoietyAnalysis = True
    return rr

#get version from VERSION file
def getTelluriumVersion():
    import os
    f = open(os.path.dirname(tellurium.__file__) +'\\VERSION.txt', 'r')
    ver = f.read().rstrip()
    f.close()
    return ver
    
# Save a string to a file
def saveToFile (fileName, str):
    """Save a string to a file. Takes two arguments, 
    the file name and the string to save:
    
    saveToFile ('c:\\myfile.txt', strVariable)"""
    outFile = open(fileName, 'w')
    outFile.write(str)
    outFile.close()
    
def readFromFile (fileName):
    """Load a file and return contents as a string, 

    str = readFromFile ('c:\\myfile.txt')"""
 
    file = open(fileName, 'r')
    return file.read()

def loadSBMLModel (sbml):
    rr = roadrunner.RoadRunner (sbml)
    rr.simulateOptions.structuredResult = False
    return rr
    
# Load an Antimony file   
def loadAntimonyModel (antStr):
    """Load an Antimony string:
    
    r = loadAntModel (antimonyStr)
    """
    err = libantimony.loadAntimonyString (antStr)
 
    if (err < 0):
       raise Exception('Antimony: ' + libantimony.getLastError())
       
    Id = libantimony.getMainModuleName()
    sbmlStr = libantimony.getSBMLString(Id)
    rr = roadrunner.RoadRunner()
    rr.simulateOptions.structuredResult = False
    rr.conservedMoietyAnalysis = True
    rr.load(sbmlStr)
    return rr

def plotWithLegend (r, result):
    """
    Plot an array and include a legend. The first argument must be a roadrunner variable. 
    The second argument must be an array containing data to plot. The first column of the array will
    be the x-axis and remaining columns the y-axis. Returns
    a handle to the plotting object.
    
    plotWithLegend (r, result)
    """
    if not isinstance (r, roadrunner.RoadRunner):
        raise Exception ('First argument must be a roadrunner variable')
{'fraction_non_alphanumeric': 0.09777582030389782, 'fraction_numerical': 0.008808632459810615, 'mean_word_length': 3.1555352241537054, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3568951', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1393, 'n_words': 469}