+/*
+ * 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;
*/
public class Gff3Helper extends GffHelperBase
{
+ public static final String ALLELES = "alleles";
+
protected static final String TARGET = "Target";
protected static final String ID = "ID";
}
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];
*/
if ("-".equals(strand))
{
- System.err
- .println("Skipping mapping from reverse complement as not yet supported");
+ System.err.println(
+ "Skipping mapping from reverse complement as not yet supported");
return null;
}
* (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)
{
* @return
*/
@SuppressWarnings("unused")
- protected String findTargetId(String target, Map<String, List<String>> set)
+ protected String findTargetId(String target,
+ Map<String, List<String>> set)
{
return target;
}
* @throws IOException
*/
protected SequenceFeature processProteinMatch(
- Map<String, List<String>> set, SequenceI seq,
- String[] gffColumns, AlignmentI align, List<SequenceI> newseqs,
+ Map<String, List<String>> set, SequenceI seq, String[] gffColumns,
+ AlignmentI align, List<SequenceI> newseqs,
boolean relaxedIdMatching)
{
// This is currently tailored to InterProScan GFF output:
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)
{
* give the mapped sequence a copy of the sequence feature, with
* start/end range adjusted
*/
- SequenceFeature sf2 = new SequenceFeature(sf);
- sf2.setBegin(1);
int sequenceFeatureLength = 1 + sf.getEnd() - sf.getBegin();
- sf2.setEnd(sequenceFeatureLength);
+ SequenceFeature sf2 = new SequenceFeature(sf, 1,
+ sequenceFeatureLength, sf.getFeatureGroup(), sf.getScore());
mappedSequence.addSequenceFeature(sf2);
/*
* renamed with its qualified accession id; renaming has to wait until
* all sequence reference resolution is complete
*/
- String accessionId = StringUtils.listToDelimitedString(
- set.get(NAME), ",");
+ String accessionId = StringUtils
+ .listToDelimitedString(set.get(NAME), ",");
if (accessionId.length() > 0)
{
String database = sf.getType(); // TODO InterProScan only??
*/
@Override
protected SequenceFeature buildSequenceFeature(String[] gff,
+ int typeColumn, String group,
Map<String, List<String>> attributes)
{
- SequenceFeature sf = super.buildSequenceFeature(gff, attributes);
+ SequenceFeature sf = super.buildSequenceFeature(gff, typeColumn, group,
+ attributes);
String desc = getDescription(sf, attributes);
if (desc != null)
{
/*
* Ensembl returns dna variants as 'alleles'
*/
- desc = StringUtils.listToDelimitedString(
- attributes.get("alleles"), ",");
+ desc = StringUtils.listToDelimitedString(attributes.get(ALLELES),
+ ",");
}
/*
desc = (String) sf.getValue(ID);
}
+ /*
+ * and decode comma, equals, semi-colon as required by GFF3 spec
+ */
+ desc = StringUtils.urlDecode(desc, GFF_ENCODABLE);
+
return desc;
}
}