+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.io.gff;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.MappingType;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
-import jalview.ext.ensembl.EnsemblSeqProxy;
import jalview.util.MapList;
import jalview.util.StringUtils;
String atts = gff[ATTRIBUTES_COL];
Map<String, List<String>> attributes = parseNameValuePairs(atts);
- if (SequenceOntology.getInstance().isProteinMatch(soTerm))
+ SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ if (so.isA(soTerm, SequenceOntologyI.PROTEIN_MATCH))
{
- sf = processProteinMatch(attributes, seq, gff, align,
- newseqs, relaxedIdMatching);
+ sf = processProteinMatch(attributes, seq, gff, align, newseqs,
+ relaxedIdMatching);
}
- else if (SequenceOntology.getInstance().isNucleotideMatch(soTerm))
+ else if (so.isA(soTerm, SequenceOntologyI.NUCLEOTIDE_MATCH))
{
- sf = processNucleotideMatch(attributes, seq, gff, align,
- newseqs, relaxedIdMatching);
+ sf = processNucleotideMatch(attributes, seq, gff, align, newseqs,
+ relaxedIdMatching);
}
else
{
*/
sf = buildSequenceFeature(gff, null);
}
-
+
return sf;
}
protected SequenceFeature processNucleotideMatch(
Map<String, List<String>> attributes, SequenceI seq,
String[] gffColumns, AlignmentI align, List<SequenceI> newseqs,
- boolean relaxedIdMatching)
- throws IOException
+ boolean relaxedIdMatching) throws IOException
{
String strand = gffColumns[STRAND_COL];
* (new or existing) virtual sequence in the newseqs list
*/
String targetId = findTargetId(tokens[0], attributes);
- SequenceI mappedSequence1 = findSequence(targetId, align,
- newseqs, relaxedIdMatching);
+ SequenceI mappedSequence1 = findSequence(targetId, align, newseqs,
+ relaxedIdMatching);
SequenceI mappedSequence = mappedSequence1;
if (mappedSequence == null)
{
int fromStart = Integer.parseInt(gffColumns[START_COL]);
int fromEnd = Integer.parseInt(gffColumns[END_COL]);
MapList mapping = constructMappingFromAlign(fromStart, fromEnd,
- toStart, toEnd,
- MappingType.NucleotideToNucleotide);
+ toStart, toEnd, MappingType.NucleotideToNucleotide);
if (mapping != null)
{
for (String target : targets)
{
- SequenceI mappedSequence1 = findSequence(findTargetId(target, set), align,
- newseqs, relaxedIdMatching);
+ SequenceI mappedSequence1 = findSequence(findTargetId(target, set),
+ align, newseqs, relaxedIdMatching);
SequenceI mappedSequence = mappedSequence1;
if (mappedSequence == null)
{
desc = target.split(" ")[0];
}
- if (SequenceOntology.getInstance().isSequenceVariant(sf.getType()))
+ SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ String type = sf.getType();
+ if (so.isA(type, SequenceOntologyI.SEQUENCE_VARIANT))
{
/*
* Ensembl returns dna variants as 'alleles'
*/
- desc = StringUtils.listToDelimitedString(
- attributes.get("alleles"), ",");
+ desc = StringUtils.listToDelimitedString(attributes.get("alleles"),
+ ",");
}
/*
- * Ensembl returns gene name as 'Name' for a transcript
+ * extract 'Name' for a transcript (to show gene name)
+ * or an exon (so 'colour by label' shows exon boundaries)
*/
- if (EnsemblSeqProxy.isTranscript(sf.getType()))
+ if (SequenceOntologyI.NMD_TRANSCRIPT_VARIANT.equals(type)
+ || so.isA(type, SequenceOntologyI.TRANSCRIPT)
+ || so.isA(type, SequenceOntologyI.EXON))
{
desc = StringUtils.listToDelimitedString(attributes.get("Name"), ",");
}
+
+ /*
+ * if the above fails, try ID
+ */
+ if (desc == null)
+ {
+ desc = (String) sf.getValue(ID);
+ }
+
return desc;
}
}