2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.api.AlignViewportI;
24 import jalview.datamodel.AlignedCodonFrame;
25 import jalview.datamodel.Alignment;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.SequenceI;
29 import java.io.IOException;
30 import java.util.List;
33 * A GFF3 File parsing wrapper for the tangled mess that is FeaturesFile.
35 * This class implements the methods relied on by FileLoader/FormatAdapter in
36 * order to allow them to load alignments directly from GFF2 and GFF3 files that
37 * contain sequence data and alignment information.
41 * 1. GFF3 files commonly include mappings between DNA, RNA and Protein - so
42 * this class needs a dataset AlignmentI context to create alignment codon
45 * 2. A single GFF3 file can generate many distinct alignments. Support will be
46 * needed to allow several AlignmentI instances to be generated from a single
53 public class Gff3File extends FeaturesFile
68 public Gff3File(FileParse source) throws IOException
78 public Gff3File(String inFile, String type) throws IOException
84 * @param parseImmediately
88 public Gff3File(boolean parseImmediately, FileParse source)
91 super(parseImmediately, source);
95 * @param parseImmediately
100 public Gff3File(boolean parseImmediately, String inFile, String type)
103 super(parseImmediately, inFile, type);
109 * @see jalview.io.FeaturesFile#print()
112 public String print()
114 // TODO GFF3 writer with sensible defaults for writing alignment data
116 // return super.printGFFFormat(seqs, visible);
117 return ("Not yet implemented.");
122 List<AlignmentI> alignments;
127 AlignViewportI av = getViewport();
130 if (av.getAlignment() != null)
132 dataset = av.getAlignment().getDataset();
136 // working in the applet context ?
137 dataset = av.getAlignment();
142 dataset = new Alignment(new SequenceI[] {});
145 boolean parseResult = parse(dataset, null, null, false, true);
148 // pass error up somehow
152 // update viewport with the dataset data ?
156 setSeqs(dataset.getSequencesArray());
162 public void addProperties(AlignmentI al)
164 super.addProperties(al);
165 if (dataset.getCodonFrames() != null)
167 AlignmentI ds = (al.getDataset() == null) ? al : al.getDataset();
168 for (AlignedCodonFrame codons : dataset.getCodonFrames())
170 ds.addCodonFrame(codons);