use of org.biojava.nbio.alignment.SimpleGapPenalty in project jstructure by JonStargaryen.
the class Start2FoldXmlParser method assignValues.
private static void assignValues(Experiment experiment, Chain chain) {
String pdbSequence = chain.getAminoAcidSequence();
String experimentSequence = experiment.getSequence();
// align sequences to ensure correct mapping
SequencePair<ProteinSequence, AminoAcidCompound> pair = null;
try {
pair = Alignments.getPairwiseAlignment(new ProteinSequence(experimentSequence), new ProteinSequence(pdbSequence), Alignments.PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), SubstitutionMatrixHelper.getBlosum62());
// logger.info("alignment:{}{}",
// System.lineSeparator(),
// pair.toString());
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
for (Experiment.Residue residue : experiment.getResidues()) {
int experimentIndex = residue.getIndex() - 1;
try {
int pdbIndex;
if (residue.getCode().equals("P") && residue.getIndex() == 1) {
// super-russian fix for STF0017 where the alignment should match theoretically
pdbIndex = 0;
} else {
pdbIndex = pair.getIndexInTargetForQueryAt(experimentIndex);
}
AminoAcid aminoAcid = aminoAcids.get(pdbIndex);
// logger.debug("mapped experiment {}-{} onto PDB {}-{}",
// residue.getCode(),
// residue.getIndex(),
// aminoAcid.getOneLetterCode(),
// aminoAcid.getResidueIdentifier());
// if(!residue.getCode().equals(aminoAcid.getOneLetterCode())) {
// logger.warn("alignment:{}{}",
// System.lineSeparator(),
// pair.toString());
// logger.warn("could not map data correctly for {}-{} and {}-{}",
// residue.getCode(),
// residue.getIndex(),
// aminoAcid.getOneLetterCode(),
// aminoAcid.getResidueIdentifier());
// }
// ignore: STF0034 (cannot align)
// assign experiment-specific protection level to residue
aminoAcid.getFeature(Start2FoldResidueAnnotation.class).addProtectionLevelEntry(Stream.of(ProtectionLevel.values()).filter(pl -> pl == experiment.getProtectionLevel()).findFirst().get());
} catch (Exception e) {
// residue not present in structure - e.g. for STF0031 and STF0032
logger.warn("alignment:{}{}", System.lineSeparator(), pair.toString());
logger.warn("failed to map residue {}-{}", residue.getCode(), residue.getIndex(), e);
}
}
} catch (CompoundNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
use of org.biojava.nbio.alignment.SimpleGapPenalty in project jstructure by JonStargaryen.
the class A01_SingleLinkageClusterer method computeNeedlemanWunschSimilarity.
/**
* Compute the Needleman-Wunsch alignment between 2 sequence and report the sequence identity.
*
* @param entry1 the reference sequence
* @param entry2 the query sequence
* @return the fraction of identically aligned positions
*/
private double computeNeedlemanWunschSimilarity(Chain entry1, Chain entry2) {
try {
ProteinSequence sequence1 = new ProteinSequence(entry1.getAminoAcidSequence());
ProteinSequence sequence2 = new ProteinSequence(entry2.getAminoAcidSequence());
SequencePair<ProteinSequence, AminoAcidCompound> pair = Alignments.getPairwiseAlignment(sequence1, sequence2, Alignments.PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), SubstitutionMatrixHelper.getBlosum62());
System.out.println(pair.getPercentageOfIdentity());
return pair.getPercentageOfIdentity();
} catch (CompoundNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
use of org.biojava.nbio.alignment.SimpleGapPenalty in project jstructure by JonStargaryen.
the class Start2FoldXmlParser method assignValues.
private static void assignValues(Experiment experiment, Chain chain) {
String pdbSequence = chain.getAminoAcidSequence();
String experimentSequence = experiment.getSequence();
// align sequences to ensure correct mapping
SequencePair<ProteinSequence, AminoAcidCompound> pair = null;
try {
pair = Alignments.getPairwiseAlignment(new ProteinSequence(experimentSequence), new ProteinSequence(pdbSequence), Alignments.PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), SubstitutionMatrixHelper.getBlosum62());
logger.debug("alignment:{}{}", System.lineSeparator(), pair.toString());
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
for (Experiment.Residue residue : experiment.getResidues()) {
int experimentIndex = residue.getIndex() - 1;
try {
int pdbIndex;
if (residue.getCode().equals("P") && residue.getIndex() == 1) {
// super-russian fix for STF0017 where the alignment should match theoretically
pdbIndex = 0;
} else {
pdbIndex = pair.getIndexInTargetForQueryAt(experimentIndex);
}
AminoAcid aminoAcid = aminoAcids.get(pdbIndex);
logger.debug("mapped experiment {}-{} onto PDB {}-{}", residue.getCode(), residue.getIndex(), aminoAcid.getOneLetterCode(), aminoAcid.getResidueIdentifier());
// if(!residue.getCode().equals(aminoAcid.getOneLetterCode())) {
// logger.warn("alignment:{}{}",
// System.lineSeparator(),
// pair.toString());
// logger.warn("could not map data correctly for {}-{} and {}-{}",
// residue.getCode(),
// residue.getIndex(),
// aminoAcid.getOneLetterCode(),
// aminoAcid.getResidueIdentifier());
// }
// ignore: STF0034 (cannot align)
// assign experiment-specific protection level to residue
aminoAcid.getFeature(Start2FoldResidueAnnotation.class).addProtectionLevelEntry(Stream.of(ProtectionLevel.values()).filter(pl -> pl == experiment.getProtectionLevel()).findFirst().get());
} catch (Exception e) {
// residue not present in structure - e.g. for STF0031 and STF0032
logger.warn("alignment:{}{}", System.lineSeparator(), pair.toString());
logger.warn("failed to map residue {}-{}", residue.getCode(), residue.getIndex(), e);
}
}
} catch (CompoundNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
use of org.biojava.nbio.alignment.SimpleGapPenalty in project jstructure by JonStargaryen.
the class Start2FoldXmlParser method assignValuesForStrong.
private static void assignValuesForStrong(Experiment experiment, Chain chain) {
String pdbSequence = chain.getAminoAcidSequence();
String experimentSequence = experiment.getSequence();
// align sequences to ensure correct mapping
SequencePair<ProteinSequence, AminoAcidCompound> pair = null;
try {
pair = Alignments.getPairwiseAlignment(new ProteinSequence(experimentSequence), new ProteinSequence(pdbSequence), Alignments.PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), SubstitutionMatrixHelper.getBlosum62());
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
for (Experiment.Residue residue : experiment.getResidues()) {
int experimentIndex = residue.getIndex() - 1;
try {
int pdbIndex;
if (residue.getCode().equals("P") && residue.getIndex() == 1) {
// super-russian fix for STF0017 where the alignment should match theoretically
pdbIndex = 0;
} else {
pdbIndex = pair.getIndexInTargetForQueryAt(experimentIndex);
}
AminoAcid aminoAcid = aminoAcids.get(pdbIndex);
// assign experiment-specific protection level to residue
aminoAcid.getFeature(Start2FoldResidueAnnotation.class).addProtectionLevelEntry(ProtectionLevel.STRONG);
} catch (Exception e) {
// residue not present in structure - e.g. for STF0031 and STF0032
logger.warn("alignment:{}{}", System.lineSeparator(), pair.toString());
logger.warn("failed to map residue {}-{}", residue.getCode(), residue.getIndex(), e);
}
}
} catch (CompoundNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
use of org.biojava.nbio.alignment.SimpleGapPenalty in project jstructure by JonStargaryen.
the class Start2FoldXmlParser method assignValuesForEarly.
private static void assignValuesForEarly(Experiment experiment, Chain chain) {
String pdbSequence = chain.getAminoAcidSequence();
String experimentSequence = experiment.getSequence();
// align sequences to ensure correct mapping
SequencePair<ProteinSequence, AminoAcidCompound> pair = null;
try {
pair = Alignments.getPairwiseAlignment(new ProteinSequence(experimentSequence), new ProteinSequence(pdbSequence), Alignments.PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), SubstitutionMatrixHelper.getBlosum62());
List<AminoAcid> aminoAcids = chain.aminoAcids().collect(Collectors.toList());
for (Experiment.Residue residue : experiment.getResidues()) {
int experimentIndex = residue.getIndex() - 1;
try {
int pdbIndex;
if (residue.getCode().equals("P") && residue.getIndex() == 1) {
// super-russian fix for STF0017 where the alignment should match theoretically
pdbIndex = 0;
} else {
pdbIndex = pair.getIndexInTargetForQueryAt(experimentIndex);
}
AminoAcid aminoAcid = aminoAcids.get(pdbIndex);
// assign experiment-specific protection level to residue
aminoAcid.getFeature(Start2FoldResidueAnnotation.class).addProtectionLevelEntry(ProtectionLevel.EARLY);
} catch (Exception e) {
// residue not present in structure - e.g. for STF0031 and STF0032
logger.warn("alignment:{}{}", System.lineSeparator(), pair.toString());
logger.warn("failed to map residue {}-{}", residue.getCode(), residue.getIndex(), e);
}
}
} catch (CompoundNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
Aggregations