}
/**
- * Helper method that adds a peptide variant feature. ID and
- * clinical_significance attributes of the dna variant (if present) are copied
- * to the new feature.
- *
- * @param peptide
- * @param peptidePos
- * @param residue
- * @param var
- * @param codon
- * the variant codon e.g. aCg
- * @param canonical
- * the 'normal' codon e.g. aTg
- * @return true if a feature was added, else false
- */
- static boolean addPeptideVariant(SequenceI peptide, int peptidePos,
- String residue, DnaVariant var, String codon, String canonical)
- {
- /*
- * get peptide translation of codon e.g. GAT -> D
- * note that variants which are not single alleles,
- * e.g. multibase variants or HGMD_MUTATION etc
- * are currently ignored here
- */
- String trans = codon.contains("-") ? null
- : (codon.length() > CODON_LENGTH ? null
- : ResidueProperties.codonTranslate(codon));
- if (trans == null)
- {
- return false;
- }
- String desc = canonical + "/" + codon;
- String featureType = "";
- if (trans.equals(residue))
- {
- featureType = SequenceOntologyI.SYNONYMOUS_VARIANT;
- }
- else if (ResidueProperties.STOP.equals(trans))
- {
- featureType = SequenceOntologyI.STOP_GAINED;
- }
- else
- {
- String residue3Char = StringUtils
- .toSentenceCase(ResidueProperties.aa2Triplet.get(residue));
- String trans3Char = StringUtils
- .toSentenceCase(ResidueProperties.aa2Triplet.get(trans));
- desc = "p." + residue3Char + peptidePos + trans3Char;
- featureType = SequenceOntologyI.NONSYNONYMOUS_VARIANT;
- }
- SequenceFeature sf = new SequenceFeature(featureType, desc, peptidePos,
- peptidePos, var.getSource());
-
- StringBuilder attributes = new StringBuilder(32);
- String id = (String) var.variant.getValue(VARIANT_ID);
- if (id != null)
- {
- if (id.startsWith(SEQUENCE_VARIANT))
- {
- id = id.substring(SEQUENCE_VARIANT.length());
- }
- sf.setValue(VARIANT_ID, id);
- attributes.append(VARIANT_ID).append("=").append(id);
- // TODO handle other species variants JAL-2064
- StringBuilder link = new StringBuilder(32);
- try
- {
- link.append(desc).append(" ").append(id).append(
- "|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=")
- .append(URLEncoder.encode(id, "UTF-8"));
- sf.addLink(link.toString());
- } catch (UnsupportedEncodingException e)
- {
- // as if
- }
- }
- String clinSig = (String) var.variant.getValue(CLINICAL_SIGNIFICANCE);
- if (clinSig != null)
- {
- sf.setValue(CLINICAL_SIGNIFICANCE, clinSig);
- attributes.append(";").append(CLINICAL_SIGNIFICANCE).append("=")
- .append(clinSig);
- }
- peptide.addSequenceFeature(sf);
- if (attributes.length() > 0)
- {
- sf.setAttributes(attributes.toString());
- }
- return true;
- }
-
- /**
* Makes an alignment with a copy of the given sequences, adding in any
* non-redundant sequences which are mapped to by the cross-referenced
* sequences.