- String type, String parentId)
- {
- List<SequenceFeature> result = new ArrayList<SequenceFeature>();
-
- SequenceFeature[] sfs = sequence.getSequenceFeatures();
- if (sfs != null) {
- SequenceOntology so = SequenceOntology.getInstance();
- for (SequenceFeature sf :sfs) {
- if (so.isA(sf.getType(), type))
- {
- String parent = (String) sf.getValue(PARENT);
- if (parent.equals(parentId))
- {
- result.add(sf);
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Maps exon features from dna to protein, and computes variants in peptide
- * product generated by variants in dna, and adds them as sequence_variant
- * features on the protein sequence. Returns the number of variant features
- * added.
- *
- * @param dnaSeq
- * @param peptide
- * @param dnaToProtein
- */
- static int computeProteinFeatures(SequenceI dnaSeq,
- SequenceI peptide, MapList dnaToProtein)
- {
- while (dnaSeq.getDatasetSequence() != null)
- {
- dnaSeq = dnaSeq.getDatasetSequence();
- }
- while (peptide.getDatasetSequence() != null)
- {
- peptide = peptide.getDatasetSequence();
- }
-
- mapExonsToProtein(dnaSeq, peptide, dnaToProtein);
-
- LinkedHashMap<Integer, String[][]> variants = buildDnaVariantsMap(
- dnaSeq, dnaToProtein);
-
- /*
- * scan codon variations, compute peptide variants and add to peptide sequence
- */
- int count = 0;
- for (Entry<Integer, String[][]> variant : variants.entrySet())
- {
- int peptidePos = variant.getKey();
- String[][] codonVariants = variant.getValue();
- String residue = String.valueOf(peptide.getCharAt(peptidePos - 1)); // 0-based
- List<String> peptideVariants = computePeptideVariants(codonVariants,
- residue);
- if (!peptideVariants.isEmpty())
- {
- Collections.sort(peptideVariants);
- String desc = StringUtils.listToDelimitedString(peptideVariants,
- ", ");
- SequenceFeature sf = new SequenceFeature(
- SequenceOntology.SEQUENCE_VARIANT, desc, peptidePos,
- peptidePos, 0f, null);
- peptide.addSequenceFeature(sf);
- count++;
- }
- }
- return count;
- }
-
- /**
- * Transfers exon features to the corresponding mapped regions of the protein
- * sequence. This is useful because it allows visualisation of exon boundaries
- * on the peptide (using 'colour by label' for the exon name). Returns the
- * number of features written.
- *
- * @param dnaSeq
- * @param peptide
- * @param dnaToProtein
- */
- static int mapExonsToProtein(SequenceI dnaSeq, SequenceI peptide,
- MapList dnaToProtein)