Search in sources :

Example 1 with ResidueType

use of ffx.potential.bonded.Residue.ResidueType in project ffx by mjschnie.

the class RotamerLibrary method addRotPatch.

private static boolean addRotPatch(File rpatchFile) {
    try (BufferedReader br = new BufferedReader(new FileReader(rpatchFile))) {
        String resName = null;
        List<String> applyLines = new ArrayList<>();
        // List<Rotamer> rotamers = new ArrayList<>();
        List<String> rotLines = new ArrayList<>();
        ResidueType rType = ResidueType.AA;
        String line = br.readLine();
        while (line != null) {
            line = line.trim();
            if (line.startsWith("PLACE")) {
                applyLines.add(line);
            } else if (line.startsWith("RESNAME")) {
                String[] toks = line.split("\\s+");
                resName = toks[1];
            } else if (line.startsWith("RESTYPE")) {
                String[] toks = line.split("\\s+");
                switch(toks[1]) {
                    case "AA":
                        rType = ResidueType.AA;
                        break;
                    case "NA":
                        rType = ResidueType.NA;
                        break;
                    case "UNK":
                    default:
                        rType = ResidueType.UNK;
                        break;
                }
            } else if (line.startsWith("ROTAMER")) {
                rotLines.add(line);
            }
            line = br.readLine();
        }
        if (resName != null) {
            List<Rotamer> rotamers = new ArrayList<>();
            for (String string : rotLines) {
                String[] toks = string.split("\\s+");
                int nVals = toks.length - 1;
                double[] values = new double[nVals];
                for (int i = 0; i < nVals; i++) {
                    values[i] = Double.parseDouble(toks[i + 1]);
                }
                switch(rType) {
                    case AA:
                        rotamers.add(new Rotamer(AminoAcid3.UNK, values));
                        break;
                    case NA:
                        rotamers.add(new Rotamer(NucleicAcid3.UNK, values));
                        break;
                    case UNK:
                    default:
                        rotamers.add(new Rotamer(values));
                        break;
                }
            }
            if (nonstdRotCache.containsKey(resName)) {
                logger.warning(String.format(" Rotamer library already contains " + "rotamer definition for residue %s!", resName));
            } else {
                NonstandardRotLibrary nrlib = new NonstandardRotLibrary(resName, applyLines.toArray(new String[applyLines.size()]), rotamers.toArray(new Rotamer[rotamers.size()]));
                nonstdRotCache.put(resName, nrlib);
            }
            return true;
        } else {
            return false;
        }
    } catch (IOException ex) {
        logger.warning(String.format(" Exception in parsing rotamer patch " + "file %s: %s", rpatchFile.getName(), ex.toString()));
        return false;
    }
}
Also used : ResidueType(ffx.potential.bonded.Residue.ResidueType) ArrayList(java.util.ArrayList) IOException(java.io.IOException) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader)

Example 2 with ResidueType

use of ffx.potential.bonded.Residue.ResidueType in project ffx by mjschnie.

the class PhMD method recursiveMap.

/**
 * Finds Titration definitions for the given Residue and adds them to the given MultiResidue.
 * For three-state transitions, simply populate the enumeration with multiple titrations
 * from a shared state and this will include them in MultiResidue construction.
 */
private void recursiveMap(Residue member, MultiResidue multiRes) {
    // Map titrations for this member.
    Titration[] titrations = Titration.multiLookup(member);
    titrationMap.put(member, Arrays.asList(titrations));
    // For each titration, check whether it needs added as a MultiResidue option.
    for (Titration titration : titrations) {
        // Allow manual override of Histidine treatment.
        if ((titration.deprotForm == AminoAcid3.HID && config.histidineMode == HistidineMode.HIE_ONLY) || (titration.deprotForm == AminoAcid3.HIE && config.histidineMode == HistidineMode.HID_ONLY)) {
            continue;
        }
        // Find all the choices currently available to this MultiResidue.
        List<AminoAcid3> choices = new ArrayList<>();
        for (Residue choice : multiRes.getConsideredResidues()) {
            choices.add(choice.getAminoAcid3());
        }
        // If this Titration target is not a choice for the MultiResidue, then add it.
        if (!choices.contains(titration.protForm) || !(choices.contains(titration.deprotForm))) {
            String targetName = (member.getAminoAcid3() == titration.protForm) ? titration.deprotForm.toString() : titration.protForm.toString();
            int resNumber = member.getResidueNumber();
            ResidueType resType = member.getResidueType();
            Residue newChoice = new Residue(targetName, resNumber, resType);
            multiRes.addResidue(newChoice);
            titrationMap.put(newChoice, Arrays.asList(Titration.multiLookup(newChoice)));
        }
    }
}
Also used : ResidueType(ffx.potential.bonded.Residue.ResidueType) TitrationUtils.inactivateResidue(ffx.potential.extended.TitrationUtils.inactivateResidue) MultiResidue(ffx.potential.bonded.MultiResidue) Residue(ffx.potential.bonded.Residue) AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3) ArrayList(java.util.ArrayList) Titration(ffx.potential.extended.TitrationUtils.Titration) TitrationUtils.performTitration(ffx.potential.extended.TitrationUtils.performTitration)

Aggregations

ResidueType (ffx.potential.bonded.Residue.ResidueType)2 ArrayList (java.util.ArrayList)2 MultiResidue (ffx.potential.bonded.MultiResidue)1 Residue (ffx.potential.bonded.Residue)1 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)1 Titration (ffx.potential.extended.TitrationUtils.Titration)1 TitrationUtils.inactivateResidue (ffx.potential.extended.TitrationUtils.inactivateResidue)1 TitrationUtils.performTitration (ffx.potential.extended.TitrationUtils.performTitration)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1