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.analysis.AlignmentUtils;
24 import jalview.analysis.SequenceIdMatcher;
25 import jalview.api.AlignViewportI;
26 import jalview.api.FeatureColourI;
27 import jalview.api.FeaturesSourceI;
28 import jalview.datamodel.AlignedCodonFrame;
29 import jalview.datamodel.Alignment;
30 import jalview.datamodel.AlignmentI;
31 import jalview.datamodel.SequenceDummy;
32 import jalview.datamodel.SequenceFeature;
33 import jalview.datamodel.SequenceI;
34 import jalview.io.gff.GffHelperBase;
35 import jalview.io.gff.GffHelperFactory;
36 import jalview.io.gff.GffHelperI;
37 import jalview.schemes.FeatureColour;
38 import jalview.schemes.UserColourScheme;
39 import jalview.util.MapList;
40 import jalview.util.ParseHtmlBodyAndLinks;
41 import jalview.util.StringUtils;
43 import java.io.IOException;
44 import java.util.ArrayList;
45 import java.util.Arrays;
46 import java.util.HashMap;
47 import java.util.Iterator;
48 import java.util.List;
50 import java.util.Map.Entry;
53 * Parses and writes features files, which may be in Jalview, GFF2 or GFF3
54 * format. These are tab-delimited formats but with differences in the use of
57 * A Jalview feature file may define feature colours and then declare that the
58 * remainder of the file is in GFF format with the line 'GFF'.
60 * GFF3 files may include alignment mappings for features, which Jalview will
61 * attempt to model, and may include sequence data following a ##FASTA line.
68 public class FeaturesFile extends AlignFile implements FeaturesSourceI
70 private static final String ID_NOT_SPECIFIED = "ID_NOT_SPECIFIED";
72 private static final String NOTE = "Note";
74 protected static final String TAB = "\t";
76 protected static final String GFF_VERSION = "##gff-version";
78 private AlignmentI lastmatchedAl = null;
80 private SequenceIdMatcher matcher = null;
82 protected AlignmentI dataset;
84 protected int gffVersion;
87 * Creates a new FeaturesFile object.
94 * Constructor which does not parse the file immediately
100 public FeaturesFile(String inFile, String type) throws IOException
102 super(false, inFile, type);
107 * @throws IOException
109 public FeaturesFile(FileParse source) throws IOException
115 * Constructor that optionally parses the file immediately
117 * @param parseImmediately
120 * @throws IOException
122 public FeaturesFile(boolean parseImmediately, String inFile, String type)
125 super(parseImmediately, inFile, type);
129 * Parse GFF or sequence features file using case-independent matching,
133 * - alignment/dataset containing sequences that are to be annotated
135 * - hashtable to store feature colour definitions
137 * - process html strings into plain text
138 * @return true if features were added
140 public boolean parse(AlignmentI align,
141 Map<String, FeatureColourI> colours,
144 return parse(align, colours, removeHTML, false);
148 * Extends the default addProperties by also adding peptide-to-cDNA mappings
149 * (if any) derived while parsing a GFF file
152 public void addProperties(AlignmentI al)
154 super.addProperties(al);
155 if (dataset != null && dataset.getCodonFrames() != null)
157 AlignmentI ds = (al.getDataset() == null) ? al : al.getDataset();
158 for (AlignedCodonFrame codons : dataset.getCodonFrames())
160 ds.addCodonFrame(codons);
166 * Parse GFF or Jalview format sequence features file
169 * - alignment/dataset containing sequences that are to be annotated
171 * - hashtable to store feature colour definitions
173 * - process html strings into plain text
174 * @param relaxedIdmatching
175 * - when true, ID matches to compound sequence IDs are allowed
176 * @return true if features were added
178 public boolean parse(AlignmentI align,
179 Map<String, FeatureColourI> colours,
180 boolean removeHTML, boolean relaxedIdmatching)
182 Map<String, String> gffProps = new HashMap<String, String>();
184 * keep track of any sequences we try to create from the data
186 List<SequenceI> newseqs = new ArrayList<SequenceI>();
192 String featureGroup = null;
194 while ((line = nextLine()) != null)
196 // skip comments/process pragmas
197 if (line.length() == 0 || line.startsWith("#"))
199 if (line.toLowerCase().startsWith("##"))
201 processGffPragma(line, gffProps, align, newseqs);
206 gffColumns = line.split("\\t"); // tab as regex
207 if (gffColumns.length == 1)
209 if (line.trim().equalsIgnoreCase("GFF"))
212 * Jalview features file with appended GFF
213 * assume GFF2 (though it may declare ##gff-version 3)
220 if (gffColumns.length > 1 && gffColumns.length < 4)
223 * if 2 or 3 tokens, we anticipate either 'startgroup', 'endgroup' or
224 * a feature type colour specification
226 String ft = gffColumns[0];
227 if (ft.equalsIgnoreCase("startgroup"))
229 featureGroup = gffColumns[1];
231 else if (ft.equalsIgnoreCase("endgroup"))
233 // We should check whether this is the current group,
234 // but at present there's no way of showing more than 1 group
239 String colscheme = gffColumns[1];
240 FeatureColourI colour = FeatureColour
241 .parseJalviewFeatureColour(colscheme);
244 colours.put(ft, colour);
251 * if not a comment, GFF pragma, startgroup, endgroup or feature
252 * colour specification, that just leaves a feature details line
253 * in either Jalview or GFF format
257 parseJalviewFeature(line, gffColumns, align, colours, removeHTML,
258 relaxedIdmatching, featureGroup);
262 parseGff(gffColumns, align, relaxedIdmatching, newseqs);
266 } catch (Exception ex)
268 // should report somewhere useful for UI if necessary
269 warningMessage = ((warningMessage == null) ? "" : warningMessage)
270 + "Parsing error at\n" + line;
271 System.out.println("Error parsing feature file: " + ex + "\n" + line);
272 ex.printStackTrace(System.err);
278 * experimental - add any dummy sequences with features to the alignment
279 * - we need them for Ensembl feature extraction - though maybe not otherwise
281 for (SequenceI newseq : newseqs)
283 if (newseq.getSequenceFeatures() != null)
285 align.addSequence(newseq);
292 * Try to parse a Jalview format feature specification and add it as a
293 * sequence feature to any matching sequences in the alignment. Returns true
294 * if successful (a feature was added), or false if not.
299 * @param featureColours
301 * @param relaxedIdmatching
302 * @param featureGroup
304 protected boolean parseJalviewFeature(String line, String[] gffColumns,
305 AlignmentI alignment, Map<String, FeatureColourI> featureColours,
306 boolean removeHTML, boolean relaxedIdMatching, String featureGroup)
309 * tokens: description seqid seqIndex start end type [score]
311 if (gffColumns.length < 6)
313 System.err.println("Ignoring feature line '" + line
314 + "' with too few columns (" + gffColumns.length + ")");
317 String desc = gffColumns[0];
318 String seqId = gffColumns[1];
319 SequenceI seq = findSequence(seqId, alignment, null, relaxedIdMatching);
321 if (!ID_NOT_SPECIFIED.equals(seqId))
323 seq = findSequence(seqId, alignment, null, relaxedIdMatching);
329 String seqIndex = gffColumns[2];
332 int idx = Integer.parseInt(seqIndex);
333 seq = alignment.getSequenceAt(idx);
334 } catch (NumberFormatException ex)
336 System.err.println("Invalid sequence index: " + seqIndex);
342 System.out.println("Sequence not found: " + line);
346 int startPos = Integer.parseInt(gffColumns[3]);
347 int endPos = Integer.parseInt(gffColumns[4]);
349 String ft = gffColumns[5];
351 if (!featureColours.containsKey(ft))
354 * Perhaps an old style groups file with no colours -
355 * synthesize a colour from the feature type
357 UserColourScheme ucs = new UserColourScheme(ft);
358 featureColours.put(ft, new FeatureColour(ucs.findColour('A')));
360 SequenceFeature sf = new SequenceFeature(ft, desc, "", startPos,
361 endPos, featureGroup);
362 if (gffColumns.length > 6)
364 float score = Float.NaN;
367 score = new Float(gffColumns[6]).floatValue();
368 // update colourgradient bounds if allowed to
369 } catch (NumberFormatException ex)
376 parseDescriptionHTML(sf, removeHTML);
378 seq.addSequenceFeature(sf);
381 && (seq = alignment.findName(seq, seqId, false)) != null)
383 seq.addSequenceFeature(new SequenceFeature(sf));
389 * clear any temporary handles used to speed up ID matching
391 protected void resetMatcher()
393 lastmatchedAl = null;
398 * Returns a sequence matching the given id, as follows
400 * <li>strict matching is on exact sequence name</li>
401 * <li>relaxed matching allows matching on a token within the sequence name,
403 * <li>first tries to find a match in the alignment sequences</li>
404 * <li>else tries to find a match in the new sequences already generated while
405 * parsing the features file</li>
406 * <li>else creates a new placeholder sequence, adds it to the new sequences
407 * list, and returns it</li>
413 * @param relaxedIdMatching
417 protected SequenceI findSequence(String seqId, AlignmentI align,
418 List<SequenceI> newseqs, boolean relaxedIdMatching)
420 // TODO encapsulate in SequenceIdMatcher, share the matcher
421 // with the GffHelper (removing code duplication)
422 SequenceI match = null;
423 if (relaxedIdMatching)
425 if (lastmatchedAl != align)
427 lastmatchedAl = align;
428 matcher = new SequenceIdMatcher(align.getSequencesArray());
431 matcher.addAll(newseqs);
434 match = matcher.findIdMatch(seqId);
438 match = align.findName(seqId, true);
439 if (match == null && newseqs != null)
441 for (SequenceI m : newseqs)
443 if (seqId.equals(m.getName()))
451 if (match == null && newseqs != null)
453 match = new SequenceDummy(seqId);
454 if (relaxedIdMatching)
456 matcher.addAll(Arrays.asList(new SequenceI[] { match }));
458 // add dummy sequence to the newseqs list
464 public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML)
466 if (sf.getDescription() == null)
470 ParseHtmlBodyAndLinks parsed = new ParseHtmlBodyAndLinks(
471 sf.getDescription(), removeHTML, newline);
473 sf.description = (removeHTML) ? parsed.getNonHtmlContent()
475 for (String link : parsed.getLinks())
483 * generate a features file for seqs includes non-pos features by default.
486 * source of sequence features
488 * hash of feature types and colours
489 * @return features file contents
491 public String printJalviewFormat(SequenceI[] sequences,
492 Map<String, FeatureColourI> visible)
494 return printJalviewFormat(sequences, visible, true, true);
498 * generate a features file for seqs with colours from visible (if any)
503 * hash of Colours for each feature type
505 * when true only feature types in 'visible' will be output
507 * indicates if non-positional features should be output (regardless
509 * @return features file contents
511 public String printJalviewFormat(SequenceI[] sequences,
512 Map<String, FeatureColourI> visible, boolean visOnly,
515 StringBuilder out = new StringBuilder(256);
516 boolean featuresGen = false;
517 if (visOnly && !nonpos && (visible == null || visible.size() < 1))
519 // no point continuing.
520 return "No Features Visible";
523 if (visible != null && visOnly)
525 // write feature colours only if we're given them and we are generating
527 // TODO: decide if feature links should also be written here ?
528 Iterator<String> en = visible.keySet().iterator();
531 String featureType = en.next().toString();
532 FeatureColourI colour = visible.get(featureType);
533 out.append(colour.toJalviewFormat(featureType)).append(newline);
537 // Work out which groups are both present and visible
538 List<String> groups = new ArrayList<String>();
540 boolean isnonpos = false;
542 SequenceFeature[] features;
543 for (int i = 0; i < sequences.length; i++)
545 features = sequences[i].getSequenceFeatures();
546 if (features != null)
548 for (int j = 0; j < features.length; j++)
550 isnonpos = features[j].begin == 0 && features[j].end == 0;
551 if ((!nonpos && isnonpos)
552 || (!isnonpos && visOnly && !visible
553 .containsKey(features[j].type)))
558 if (features[j].featureGroup != null
559 && !groups.contains(features[j].featureGroup))
561 groups.add(features[j].featureGroup);
570 if (groups.size() > 0 && groupIndex < groups.size())
572 group = groups.get(groupIndex);
574 out.append("STARTGROUP").append(TAB);
583 for (int i = 0; i < sequences.length; i++)
585 features = sequences[i].getSequenceFeatures();
586 if (features != null)
588 for (SequenceFeature sequenceFeature : features)
590 isnonpos = sequenceFeature.begin == 0 && sequenceFeature.end == 0;
591 if ((!nonpos && isnonpos)
592 || (!isnonpos && visOnly && !visible
593 .containsKey(sequenceFeature.type)))
595 // skip if feature is nonpos and we ignore them or if we only
596 // output visible and it isn't non-pos and it's not visible
601 && (sequenceFeature.featureGroup == null || !sequenceFeature.featureGroup
607 if (group == null && sequenceFeature.featureGroup != null)
611 // we have features to output
613 if (sequenceFeature.description == null
614 || sequenceFeature.description.equals(""))
616 out.append(sequenceFeature.type).append(TAB);
620 if (sequenceFeature.links != null
621 && sequenceFeature.getDescription().indexOf("<html>") == -1)
623 out.append("<html>");
626 out.append(sequenceFeature.description);
627 if (sequenceFeature.links != null)
629 for (int l = 0; l < sequenceFeature.links.size(); l++)
631 String label = sequenceFeature.links.elementAt(l);
632 String href = label.substring(label.indexOf("|") + 1);
633 label = label.substring(0, label.indexOf("|"));
635 if (sequenceFeature.description.indexOf(href) == -1)
637 out.append(" <a href=\"" + href + "\">" + label
642 if (sequenceFeature.getDescription().indexOf("</html>") == -1)
644 out.append("</html>");
650 out.append(sequences[i].getName());
651 out.append("\t-1\t");
652 out.append(sequenceFeature.begin);
654 out.append(sequenceFeature.end);
656 out.append(sequenceFeature.type);
657 if (!Float.isNaN(sequenceFeature.score))
660 out.append(sequenceFeature.score);
669 out.append("ENDGROUP").append(TAB);
679 } while (groupIndex < groups.size() + 1);
683 return "No Features Visible";
686 return out.toString();
690 * Parse method that is called when a GFF file is dragged to the desktop
695 AlignViewportI av = getViewport();
698 if (av.getAlignment() != null)
700 dataset = av.getAlignment().getDataset();
704 // working in the applet context ?
705 dataset = av.getAlignment();
710 dataset = new Alignment(new SequenceI[] {});
713 boolean parseResult = parse(dataset, null, false, true);
716 // pass error up somehow
720 // update viewport with the dataset data ?
724 setSeqs(dataset.getSequencesArray());
729 * Implementation of unused abstract method
731 * @return error message
734 public String print()
736 return "Use printGffFormat() or printJalviewFormat()";
740 * Returns features output in GFF2 format, including hidden and non-positional
744 * the sequences whose features are to be output
746 * a map whose keys are the type names of visible features
749 public String printGffFormat(SequenceI[] sequences,
750 Map<String, FeatureColourI> visible)
752 return printGffFormat(sequences, visible, true, true);
756 * Returns features output in GFF2 format
759 * the sequences whose features are to be output
761 * a map whose keys are the type names of visible features
762 * @param outputVisibleOnly
763 * @param includeNonPositionalFeatures
766 public String printGffFormat(SequenceI[] sequences,
767 Map<String, FeatureColourI> visible, boolean outputVisibleOnly,
768 boolean includeNonPositionalFeatures)
770 StringBuilder out = new StringBuilder(256);
771 int version = gffVersion == 0 ? 2 : gffVersion;
772 out.append(String.format("%s %d\n", GFF_VERSION, version));
775 for (SequenceI seq : sequences)
777 SequenceFeature[] features = seq.getSequenceFeatures();
778 if (features != null)
780 for (SequenceFeature sf : features)
782 isnonpos = sf.begin == 0 && sf.end == 0;
783 if (!includeNonPositionalFeatures && isnonpos)
786 * ignore non-positional features if not wanted
790 // TODO why the test !isnonpos here?
791 // what about not visible non-positional features?
792 if (!isnonpos && outputVisibleOnly
793 && !visible.containsKey(sf.type))
796 * ignore not visible features if not wanted
801 source = sf.featureGroup;
804 source = sf.getDescription();
807 out.append(seq.getName());
813 out.append(sf.begin);
817 out.append(sf.score);
820 int strand = sf.getStrand();
821 out.append(strand == 1 ? "+" : (strand == -1 ? "-" : "."));
824 String phase = sf.getPhase();
825 out.append(phase == null ? "." : phase);
827 // miscellaneous key-values (GFF column 9)
828 String attributes = sf.getAttributes();
829 if (attributes != null)
831 out.append(TAB).append(attributes);
839 return out.toString();
843 * Returns a mapping given list of one or more Align descriptors (exonerate
846 * @param alignedRegions
847 * a list of "Align fromStart toStart fromCount"
848 * @param mapIsFromCdna
849 * if true, 'from' is dna, else 'from' is protein
851 * either 1 (forward) or -1 (reverse)
853 * @throws IOException
855 protected MapList constructCodonMappingFromAlign(
856 List<String> alignedRegions, boolean mapIsFromCdna, int strand)
861 throw new IOException(
862 "Invalid strand for a codon mapping (cannot be 0)");
864 int regions = alignedRegions.size();
865 // arrays to hold [start, end] for each aligned region
866 int[] fromRanges = new int[regions * 2]; // from dna
867 int[] toRanges = new int[regions * 2]; // to protein
868 int fromRangesIndex = 0;
869 int toRangesIndex = 0;
871 for (String range : alignedRegions)
874 * Align mapFromStart mapToStart mapFromCount
875 * e.g. if mapIsFromCdna
876 * Align 11270 143 120
878 * 120 bases from pos 11270 align to pos 143 in peptide
879 * if !mapIsFromCdna this would instead be
882 String[] tokens = range.split(" ");
883 if (tokens.length != 3)
885 throw new IOException("Wrong number of fields for Align");
892 fromStart = Integer.parseInt(tokens[0]);
893 toStart = Integer.parseInt(tokens[1]);
894 fromCount = Integer.parseInt(tokens[2]);
895 } catch (NumberFormatException nfe)
897 throw new IOException("Invalid number in Align field: "
902 * Jalview always models from dna to protein, so adjust values if the
903 * GFF mapping is from protein to dna
908 int temp = fromStart;
912 fromRanges[fromRangesIndex++] = fromStart;
913 fromRanges[fromRangesIndex++] = fromStart + strand * (fromCount - 1);
916 * If a codon has an intron gap, there will be contiguous 'toRanges';
917 * this is handled for us by the MapList constructor.
918 * (It is not clear that exonerate ever generates this case)
920 toRanges[toRangesIndex++] = toStart;
921 toRanges[toRangesIndex++] = toStart + (fromCount - 1) / 3;
924 return new MapList(fromRanges, toRanges, 3, 1);
928 * Parse a GFF format feature. This may include creating a 'dummy' sequence to
929 * hold the feature, or for its mapped sequence, or both, to be resolved
930 * either later in the GFF file (##FASTA section), or when the user loads
931 * additional sequences.
935 * @param relaxedIdMatching
939 protected SequenceI parseGff(String[] gffColumns, AlignmentI alignment,
940 boolean relaxedIdMatching, List<SequenceI> newseqs)
943 * GFF: seqid source type start end score strand phase [attributes]
945 if (gffColumns.length < 5)
947 System.err.println("Ignoring GFF feature line with too few columns ("
948 + gffColumns.length + ")");
953 * locate referenced sequence in alignment _or_
954 * as a forward or external reference (SequenceDummy)
956 String seqId = gffColumns[0];
957 SequenceI seq = findSequence(seqId, alignment, newseqs,
960 SequenceFeature sf = null;
961 GffHelperI helper = GffHelperFactory.getHelper(gffColumns);
966 sf = helper.processGff(seq, gffColumns, alignment, newseqs,
970 seq.addSequenceFeature(sf);
971 while ((seq = alignment.findName(seq, seqId, true)) != null)
973 seq.addSequenceFeature(new SequenceFeature(sf));
976 } catch (IOException e)
978 System.err.println("GFF parsing failed with: " + e.getMessage());
987 * Process the 'column 9' data of the GFF file. This is less formally defined,
988 * and its interpretation will vary depending on the tool that has generated
994 protected void processGffColumnNine(String attributes, SequenceFeature sf)
996 sf.setAttributes(attributes);
999 * Parse attributes in column 9 and add them to the sequence feature's
1000 * 'otherData' table; use Note as a best proxy for description
1002 char nameValueSeparator = gffVersion == 3 ? '=' : ' ';
1003 // TODO check we don't break GFF2 values which include commas here
1004 Map<String, List<String>> nameValues = GffHelperBase
1005 .parseNameValuePairs(attributes, ";", nameValueSeparator, ",");
1006 for (Entry<String, List<String>> attr : nameValues.entrySet())
1008 String values = StringUtils.listToDelimitedString(attr.getValue(),
1010 sf.setValue(attr.getKey(), values);
1011 if (NOTE.equals(attr.getKey()))
1013 sf.setDescription(values);
1019 * After encountering ##fasta in a GFF3 file, process the remainder of the
1020 * file as FAST sequence data. Any placeholder sequences created during
1021 * feature parsing are updated with the actual sequences.
1025 * @throws IOException
1027 protected void processAsFasta(AlignmentI align, List<SequenceI> newseqs)
1033 } catch (IOException q)
1036 FastaFile parser = new FastaFile(this);
1037 List<SequenceI> includedseqs = parser.getSeqs();
1039 SequenceIdMatcher smatcher = new SequenceIdMatcher(newseqs);
1042 * iterate over includedseqs, and replacing matching ones with newseqs
1043 * sequences. Generic iterator not used here because we modify
1044 * includedseqs as we go
1046 for (int p = 0, pSize = includedseqs.size(); p < pSize; p++)
1048 // search for any dummy seqs that this sequence can be used to update
1049 SequenceI includedSeq = includedseqs.get(p);
1050 SequenceI dummyseq = smatcher.findIdMatch(includedSeq);
1051 if (dummyseq != null && dummyseq instanceof SequenceDummy)
1053 // probably have the pattern wrong
1054 // idea is that a flyweight proxy for a sequence ID can be created for
1055 // 1. stable reference creation
1056 // 2. addition of annotation
1057 // 3. future replacement by a real sequence
1058 // current pattern is to create SequenceDummy objects - a convenience
1059 // constructor for a Sequence.
1060 // problem is that when promoted to a real sequence, all references
1061 // need to be updated somehow. We avoid that by keeping the same object.
1062 ((SequenceDummy) dummyseq).become(includedSeq);
1063 dummyseq.createDatasetSequence();
1066 * Update mappings so they are now to the dataset sequence
1068 for (AlignedCodonFrame mapping : align.getCodonFrames())
1070 mapping.updateToDataset(dummyseq);
1074 * replace parsed sequence with the realised forward reference
1076 includedseqs.set(p, dummyseq);
1079 * and remove from the newseqs list
1081 newseqs.remove(dummyseq);
1086 * finally add sequences to the dataset
1088 for (SequenceI seq : includedseqs)
1090 // experimental: mapping-based 'alignment' to query sequence
1091 AlignmentUtils.alignSequenceAs(seq, align,
1092 String.valueOf(align.getGapCharacter()), false, true);
1094 // rename sequences if GFF handler requested this
1095 // TODO a more elegant way e.g. gffHelper.postProcess(newseqs) ?
1096 SequenceFeature[] sfs = seq.getSequenceFeatures();
1099 String newName = (String) sfs[0].getValue(GffHelperI.RENAME_TOKEN);
1100 if (newName != null)
1102 seq.setName(newName);
1105 align.addSequence(seq);
1110 * Process a ## directive
1116 * @throws IOException
1118 protected void processGffPragma(String line,
1119 Map<String, String> gffProps, AlignmentI align,
1120 List<SequenceI> newseqs) throws IOException
1123 if ("###".equals(line))
1125 // close off any open 'forward references'
1129 String[] tokens = line.substring(2).split(" ");
1130 String pragma = tokens[0];
1131 String value = tokens.length == 1 ? null : tokens[1];
1133 if ("gff-version".equalsIgnoreCase(pragma))
1139 // value may be e.g. "3.1.2"
1140 gffVersion = Integer.parseInt(value.split("\\.")[0]);
1141 } catch (NumberFormatException e)
1147 else if ("sequence-region".equalsIgnoreCase(pragma))
1149 // could capture <seqid start end> if wanted here
1151 else if ("feature-ontology".equalsIgnoreCase(pragma))
1153 // should resolve against the specified feature ontology URI
1155 else if ("attribute-ontology".equalsIgnoreCase(pragma))
1157 // URI of attribute ontology - not currently used in GFF3
1159 else if ("source-ontology".equalsIgnoreCase(pragma))
1161 // URI of source ontology - not currently used in GFF3
1163 else if ("species-build".equalsIgnoreCase(pragma))
1165 // save URI of specific NCBI taxon version of annotations
1166 gffProps.put("species-build", value);
1168 else if ("fasta".equalsIgnoreCase(pragma))
1170 // process the rest of the file as a fasta file and replace any dummy
1172 processAsFasta(align, newseqs);
1176 System.err.println("Ignoring unknown pragma: " + line);