Esempio n. 1
0
      def genfile_gts(self,filename,level=""):
          write_gtsfile(self._xcc,self._atnums,self._ch,self._mtp,\
                  self._V0,self._pgroup,self._rotsigma,self._gcc,\
                  self._Fcc,filename,level=level)

          try   : write_gtsfile(self._xcc,self._atnums,self._ch,self._mtp,\
                  self._V0,self._pgroup,self._rotsigma,self._gcc,\
                  self._Fcc,filename,level=level)
          except: return 0
          return 1
Esempio n. 2
0
def userfile_to_gtsfile(filename, gtsfile):
    '''
    Read a file given by the user and generate gts file
    if possible
    '''
    gtsfile = gtsname(gtsfile, "full")
    read_methods = []
    read_methods.append(read_gtsfile)  #(a) a gts file
    read_methods.append(read_fchk)  #(b) a fchk file
    read_methods.append(read_gauout)  #(c) a Gaussian output file
    read_methods.append(read_orca)  #(d) an Orca output file
    for read_method in read_methods:
        try:
            xcc, atonums, ch, mtp, E, gcc, Fcc, masses, clevel = read_method(
                filename)[0:9]
            if read_method == read_gtsfile: clevel = ""
            # in case no data in masses
            if masses is None or len(masses) == 0 or sum(masses) == 0.0:
                masses = atonums2masses(atonums)
            # get point group
            pgroup, rotsigma = get_pgs(atonums, masses, xcc)
            # write gts
            write_gtsfile(xcc,
                          atonums,
                          ch,
                          mtp,
                          E,
                          pgroup,
                          rotsigma,
                          gcc,
                          Fcc,
                          gtsfile,
                          level=clevel)
            return 1, E
        except Exc.FileType:
            continue
        except:
            continue
    return 0, None
Esempio n. 3
0
def analyze_filefolder(ff, dtrack):

    global sthwrong
    global wrong1
    global wrong2

    iblank = "         "

    # Is ff a folder or a file?
    if os.path.isdir(PN.UFOLDER + ff):
        # Get CTC name & list of files
        ctc_name = ff[:-1]
        files = sorted(
            [ff + filename for filename in os.listdir(PN.UFOLDER + ff)])
        print "         |--> %s" % ff
        iblank += "     "
    else:
        # Get CTC name & list of files
        ctc_name = ff.split(".")[0]
        files = [ff]

    # valid name??
    if not is_string_valid(ctc_name, extra="_"):
        print iblank + "|--> %s (invalid name!)" % ff
        sthwrong = True
        wrong1 = True
        return None

    # only files with known extension
    files = known_files(files)

    # Convert to gts (provisional name)
    count = 1
    gtslist = []
    for ifile in files:
        # read file
        data = data_from_file(PN.UFOLDER + ifile)
        # print info
        if ifile in dtrack.keys():
            print iblank + "|--> %s (in %s)" % (ifile.split("/")[-1],
                                                PN.IFILE0)
            continue
        elif data is None:
            print iblank + "|--> %s (reading fails!)" % (ifile.split("/")[-1])
            sthwrong = True
            wrong2 = True
            continue
        else:
            print iblank + "|--> %s (new)" % (ifile.split("/")[-1])
        while True:
            prov_gts = PN.DIR1 + "%s.gts_%i" % (ctc_name, count)
            count += 1
            if not os.path.exists(prov_gts): break
        # expand data
        xcc, atonums, ch, mtp, E, gcc, Fcc, masses, clevel = data
        # get point group
        pgroup, rotsigma = get_pgs(atonums, masses, xcc)
        # write gts (provisional)
        if not os.path.exists(PN.DIR1): os.mkdir(PN.DIR1)
        write_gtsfile(xcc,
                      atonums,
                      ch,
                      mtp,
                      E,
                      pgroup,
                      rotsigma,
                      gcc,
                      Fcc,
                      prov_gts,
                      level=clevel)
        gtslist.append((E, ifile, prov_gts))

    # sort by energy (only those created)
    gtslist.sort()

    # Rename gts files
    info, idx = [], 1
    for E, ifile, prov_gts in gtslist:
        while True:
            ofile = ctc_name + ".%003i.gts" % (idx)
            idx += 1
            if ofile in dtrack.values(): continue
            if not os.path.exists(PN.DIR1 + ofile): break

        os.rename(prov_gts, PN.DIR1 + ofile)
        info.append((E, ifile, ofile))
    return info