Ejemplo n.º 1
0
def RunAnalTrj(TrjFile,
               PrmtopFile,
               OutputPath=None,
               Prefix=None,
               NSkip=0,
               NRead=None,
               NStride=1):
    "Runs a mesostring analysis of a trajectory."
    #make the coords object
    CoordsObj = coords.TrjClass(TrjFile,
                                PrmtopFile,
                                NSkip=NSkip,
                                NRead=NRead,
                                NStride=NStride)
    ConfMeso, MesoPop, MesoEntropy = RunAnal(CoordsObj, OutputPath, Prefix)
    return ConfMeso, MesoPop, MesoEntropy
Ejemplo n.º 2
0
    #get options
    Align = "align" in Args["FLAGS"]
    CompResInd = GetResList(Args.get("compres", None))
    CalcResInd = GetResList(Args.get("calcres", None))

    #check for a trajectory
    if "traj" in Args["FLAGS"]:
        PdbRef, TrjFile, PrmtopFile = Args["ARGS"][:3]
        NAvg = int(Args.get("avg", 1))
        Cut = float(Args.get("frac", 0.))
        NSkip = int(Args.get("nskip", 0))
        NRead = int(Args.get("nread", -1))
        NStride = int(Args.get("nstride", 1))
        Trj = coords.TrjClass(TrjFile,
                              PrmtopFile,
                              NSkip=NSkip,
                              NRead=NRead,
                              NStride=NStride)
        pTrj = protein.ProteinClass()
        pTrj.LinkTrj(Trj)
        pRef = protein.ProteinClass(Pdb=PdbRef)
        print "%-10s %-8s %-8s %-5s" % ("Frame", "BB_RMSD", "All_RMSD", "NRes")
        i = 0
        y1, y2 = [], []
        z1, z2 = [], []
        for Pos in Trj:
            i += 1
            x1, NRes = RMSDProteinClass(pRef,
                                        pTrj,
                                        Backbone=True,
                                        AlignSeq=Align,
Ejemplo n.º 3
0
    DihThresh = Args["dihthresh"]
    SSThresh = Args["ssthresh"]
    NSkip, NRead, NStride = Args["nskip"], Args["nread"], Args["nstride"]
    WriteZam = "writezam" in Args["FLAGS"]
    Verbose = not "quiet" in Args["FLAGS"]
    ScaleDih = "scaledih" in Args["FLAGS"]
    ScaleCont = "scalecont" in Args["FLAGS"]
    DihFConst = Args["dihfconst"]
    ContFConst = Args["contfconst"]
    ZamInputs = "zaminputs" in Args["FLAGS"]
    PhobicsOnly = "phobics" in Args["FLAGS"]
    RunSS = "runss" in Args["FLAGS"]
    #check the input files
    Files = [x for x in Args["ARGS"][1:] if os.path.isfile(x)]
    if all([".pdb" in x for x in Files]):
        CObj = coords.PdbListClass(Files)
    else:
        CObj = coords.TrjClass(Files[0],
                               Files[1],
                               NSkip=NSkip,
                               NRead=NRead,
                               NStride=NStride)
    #get common parameters from consensus
    Seq, Contacts, ResSS, ResSSFrac, FixedDih = GetCommon(CObj,
                                                          RunSS,
                                                          Verbose=Verbose)
    #write zam output
    if ZamInputs:
        WriteZamFiles(".", FixedDih, Contacts, DihFConst, ContFConst,
                      ScaleCont)
Ejemplo n.º 4
0
def SaveTrjDists(TrjFile,
                 PrmtopFile,
                 OutputPath,
                 PairAtoms,
                 PairLabels=None,
                 NSkip=0,
                 NRead=None,
                 NStride=1,
                 Prefix="",
                 Verbose=VerboseDflt):
    """Saves distances from a trajectory to a gzipped file.
* TrjFile: string, path of trajectory file
* PrmtopFile: string, path of prmtop file
* OutputPath: string, path to save distance file(s)
* PairAtoms: list of pairs of lists of atom numbers
* PairLabels: list of labels for each distance pair
* NSkip: number of configurations to skip
* NRead: maximum number of configurations to read (default is all)
* NStride: stride between configuration frames (default is 1)
* Prefix: string, prefix to add to the name of the distance file
* Verbose: boolean, display verbose messages?"""
    #make sure any pairs are specified
    if len(PairAtoms) == 0:
        return
    #convert to groups
    GroupAtoms, PairGroups = MakeAtomGroups(PairAtoms)
    NGroup = len(GroupAtoms)
    #make trj object
    Trj = coords.TrjClass(TrjFile,
                          PrmtopFile,
                          NSkip=NSkip,
                          NRead=NRead,
                          NStride=NStride)
    #check labels
    if PairLabels is None:
        PairLabels = ["pair%d" % i for i in range(0, len(PairAtoms))]
    #open the output file output the header
    ColHead = ["index".ljust(BlockLen)
               ] + [s.ljust(BlockLen) for s in PairLabels]
    fn = os.path.join(OutputPath, Prefix + "dist.txt.gz")
    f = gzip.GzipFile(fn, "w")
    f.write("".join(ColHead) + "\n")
    #initialize variables
    GroupPos = zeros((NGroup, 3), float)
    #now parse the trajectory
    for Pos in Trj:
        #calculate the centroid of group coordinates
        GroupPos.fill(0.)
        for i in range(0, NGroup):
            Group = GroupAtoms[i]
            for AtomNum in Group:
                GroupPos[i, :] += Pos[AtomNum, :]
            GroupPos[i, :] /= float(len(Group))
        #calculate the distances
        DistList = []
        for Group1, Group2 in PairGroups:
            Dist = sqrt(sum((GroupPos[Group1, :] - GroupPos[Group2, :])**2))
            DistList.append(Dist)
        #output to file
        s = ("%d" % Trj.Index).ljust(BlockLen - 1) + " "
        s += " ".join([(DistFmt % d).ljust(BlockLen - 1) for d in DistList])
        s += "\n"
        f.write(s)
    f.close()
    Trj.Close()
Ejemplo n.º 5
0
    MinDist=float(ARGS[input+1])
  elif ARGS[input].startswith('-max'):
    MaxDist=float(ARGS[input+1])
  elif ARGS[input].startswith('-x'):
    mdcrd=ARGS[input+1]
  elif ARGS[input].startswith('-skip'):
    nskip=int(ARGS[input+1])
  elif ARGS[input].startswith('-int'):
    nstride=int(ARGS[input+1])
  elif ARGS[input].startswith('-'):
    print str(ARGS[input]) + " flag is not recognized\n"
    sys.exit()


#open the trajectory file
Trj = coords.TrjClass(str(Trjfn),str(Prmtopfn), NSkip=nskip, NStride=nstride)
NDigits = int(log(len(Trj) + 0.1) / log(10.) + 1.)
print "Found %d snapshots in trajectory file" % len(Trj)

#link a proteinclass object
p = protein.ProteinClass()
p.LinkTrj(Trj)
pdbfiles=[]

#check residues
if ResNum1 > len(p):
  print "Error: first residue number exceeds protein length."
  sys.exit()
if ResNum2 > len(p):
  print "Error: second residue number exceeds protein length."
  sys.exit()