示例#1
0
    def setUp(self):
        self.instring = "A + B -2.0>\tC +\tB"
        #this string includes:
        #  different kinds of whitespace
        #  disordered products
        #  floating-point rate
        self.net = ReactionNetwork.from_string(self.instring)

        self.othernet = ReactionNetwork.from_string(self.instring)

        self.wrongstring = "A + B\t-3.0> C + B"
        self.wrongnet = ReactionNetwork.from_string(self.wrongstring)
 def setUp(self):
     self.instring = "A + B -2.0>\tC +\tB"
     #this string includes:
     #  different kinds of whitespace
     #  disordered products
     #  floating-point rate
     self.net = ReactionNetwork.from_string(self.instring)
     
     self.othernet = ReactionNetwork.from_string(self.instring)
     
     self.wrongstring = "A + B\t-3.0> C + B"
     self.wrongnet = ReactionNetwork.from_string(self.wrongstring)
示例#3
0
def main():
    parser = optparse.OptionParser(
        description="Pretty-printer and syntax checker for .chem files.")
    parser.add_option("-i",
                      "--infile",
                      dest="infile",
                      help="read from INFILE (if ommited, use stdin)",
                      metavar="INFILE")
    parser.add_option(
        "-o",
        "--outfile",
        dest="outfile",
        help="write to OUTFILE in .chem format (if ommited, use stdout)",
        metavar="OUTFILE")
    (options, args) = parser.parse_args()
    rn = None
    if options.infile is None:
        #read from standard in
        rn = ReactionNetwork.from_string(sys.stdin.read())
    else:
        #read from provided filename
        rn = ReactionNetwork.from_filename(options.infile)

    chemstr = str(rn)

    if options.outfile is None:
        #print to standard out
        sys.stdout.write(chemstr)
    else:
        #write to provided filename
        outfile = open(options.outfile, "w")
        outfile.write(chemstr)
        outfile.close()
示例#4
0
def main():
    parser = optparse.OptionParser(description="Produces `.dot` output from `.chem` input.")
    parser.add_option("-i", "--infile",  dest="infile",  help="read from INFILE in .chem format (if ommited, use stdin)", metavar="INFILE")
    parser.add_option("-o", "--outfile", dest="outfile", help="write to OUTFILE in .dot format (if ommited, use stdout)", metavar="OUTFILE")
    parser.add_option("-n", "--names", dest="names", help="style of molecular species naming. One of 'full', 'id', 'blank'", metavar="NAMES", default=None)
    parser.add_option("-l", "--layout", dest="layout", help="layout to assign to the dot file")
    
    (options, args) = parser.parse_args()
    rn = None
    if options.infile is None:
        #read from standard in
        rn = ReactionNetwork.from_string(sys.stdin.read())
    else:
        #read from provided filename
        rn = ReactionNetwork.from_filename(options.infile)

    
    dot = net_to_dot(rn, names=options.names)
    if options.layout is not None:
        dot["graph"]["layout"] = options.layout
        
    dotstr = str(dot)

    if options.outfile is None:
        #print to standard out
        sys.stdout.write(dotstr)
    else:
        #write to provided filename
        outfile = open(options.outfile, "w")
        outfile.write(dotstr)
        outfile.close()
示例#5
0
def main():
    parser = optparse.OptionParser(description="Pretty-printer and syntax checker for .chem files.")
    parser.add_option(
        "-i", "--infile", dest="infile", help="read from INFILE (if ommited, use stdin)", metavar="INFILE"
    )
    parser.add_option(
        "-o",
        "--outfile",
        dest="outfile",
        help="write to OUTFILE in .chem format (if ommited, use stdout)",
        metavar="OUTFILE",
    )
    (options, args) = parser.parse_args()
    rn = None
    if options.infile is None:
        # read from standard in
        rn = ReactionNetwork.from_string(sys.stdin.read())
    else:
        # read from provided filename
        rn = ReactionNetwork.from_filename(options.infile)

    chemstr = str(rn)

    if options.outfile is None:
        # print to standard out
        sys.stdout.write(chemstr)
    else:
        # write to provided filename
        outfile = open(options.outfile, "w")
        outfile.write(chemstr)
        outfile.close()