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.util.ColorUtils;
39 import jalview.util.MapList;
40 import jalview.util.ParseHtmlBodyAndLinks;
41 import jalview.util.StringUtils;
43 import java.awt.Color;
44 import java.io.IOException;
45 import java.util.ArrayList;
46 import java.util.Arrays;
47 import java.util.Collections;
48 import java.util.HashMap;
49 import java.util.List;
51 import java.util.Map.Entry;
54 * Parses and writes features files, which may be in Jalview, GFF2 or GFF3
55 * format. These are tab-delimited formats but with differences in the use of
58 * A Jalview feature file may define feature colours and then declare that the
59 * remainder of the file is in GFF format with the line 'GFF'.
61 * GFF3 files may include alignment mappings for features, which Jalview will
62 * attempt to model, and may include sequence data following a ##FASTA line.
69 public class FeaturesFile extends AlignFile implements FeaturesSourceI
71 private static final String ID_NOT_SPECIFIED = "ID_NOT_SPECIFIED";
73 private static final String NOTE = "Note";
75 protected static final String TAB = "\t";
77 protected static final String GFF_VERSION = "##gff-version";
79 private AlignmentI lastmatchedAl = null;
81 private SequenceIdMatcher matcher = null;
83 protected AlignmentI dataset;
85 protected int gffVersion;
88 * Creates a new FeaturesFile object.
95 * Constructor which does not parse the file immediately
101 public FeaturesFile(String file, DataSourceType paste)
104 super(false, file, paste);
109 * @throws IOException
111 public FeaturesFile(FileParse source) throws IOException
117 * Constructor that optionally parses the file immediately
119 * @param parseImmediately
122 * @throws IOException
124 public FeaturesFile(boolean parseImmediately, String file,
125 DataSourceType type) throws IOException
127 super(parseImmediately, file, type);
131 * Parse GFF or sequence features file using case-independent matching,
135 * - alignment/dataset containing sequences that are to be annotated
137 * - hashtable to store feature colour definitions
139 * - process html strings into plain text
140 * @return true if features were added
142 public boolean parse(AlignmentI align,
143 Map<String, FeatureColourI> colours, boolean removeHTML)
145 return parse(align, colours, removeHTML, false);
149 * Extends the default addProperties by also adding peptide-to-cDNA mappings
150 * (if any) derived while parsing a GFF file
153 public void addProperties(AlignmentI al)
155 super.addProperties(al);
156 if (dataset != null && dataset.getCodonFrames() != null)
158 AlignmentI ds = (al.getDataset() == null) ? al : al.getDataset();
159 for (AlignedCodonFrame codons : dataset.getCodonFrames())
161 ds.addCodonFrame(codons);
167 * Parse GFF or Jalview format sequence features file
170 * - alignment/dataset containing sequences that are to be annotated
172 * - hashtable to store feature colour definitions
174 * - process html strings into plain text
175 * @param relaxedIdmatching
176 * - when true, ID matches to compound sequence IDs are allowed
177 * @return true if features were added
179 public boolean parse(AlignmentI align,
180 Map<String, FeatureColourI> colours, boolean removeHTML,
181 boolean relaxedIdmatching)
183 Map<String, String> gffProps = new HashMap<String, String>();
185 * keep track of any sequences we try to create from the data
187 List<SequenceI> newseqs = new ArrayList<SequenceI>();
193 String featureGroup = null;
195 while ((line = nextLine()) != null)
197 // skip comments/process pragmas
198 if (line.length() == 0 || line.startsWith("#"))
200 if (line.toLowerCase().startsWith("##"))
202 processGffPragma(line, gffProps, align, newseqs);
207 gffColumns = line.split("\\t"); // tab as regex
208 if (gffColumns.length == 1)
210 if (line.trim().equalsIgnoreCase("GFF"))
213 * Jalview features file with appended GFF
214 * assume GFF2 (though it may declare ##gff-version 3)
221 if (gffColumns.length > 1 && gffColumns.length < 4)
224 * if 2 or 3 tokens, we anticipate either 'startgroup', 'endgroup' or
225 * a feature type colour specification
227 String ft = gffColumns[0];
228 if (ft.equalsIgnoreCase("startgroup"))
230 featureGroup = gffColumns[1];
232 else if (ft.equalsIgnoreCase("endgroup"))
234 // We should check whether this is the current group,
235 // but at present there's no way of showing more than 1 group
240 String colscheme = gffColumns[1];
241 FeatureColourI colour = FeatureColour
242 .parseJalviewFeatureColour(colscheme);
245 colours.put(ft, colour);
252 * if not a comment, GFF pragma, startgroup, endgroup or feature
253 * colour specification, that just leaves a feature details line
254 * in either Jalview or GFF format
258 parseJalviewFeature(line, gffColumns, align, colours, removeHTML,
259 relaxedIdmatching, featureGroup);
263 parseGff(gffColumns, align, relaxedIdmatching, newseqs);
267 } catch (Exception ex)
269 // should report somewhere useful for UI if necessary
270 warningMessage = ((warningMessage == null) ? "" : warningMessage)
271 + "Parsing error at\n" + line;
272 System.out.println("Error parsing feature file: " + ex + "\n" + line);
273 ex.printStackTrace(System.err);
279 * experimental - add any dummy sequences with features to the alignment
280 * - we need them for Ensembl feature extraction - though maybe not otherwise
282 for (SequenceI newseq : newseqs)
284 if (newseq.getFeatures().hasFeatures())
286 align.addSequence(newseq);
293 * Try to parse a Jalview format feature specification and add it as a
294 * sequence feature to any matching sequences in the alignment. Returns true
295 * if successful (a feature was added), or false if not.
300 * @param featureColours
302 * @param relaxedIdmatching
303 * @param featureGroup
305 protected boolean parseJalviewFeature(String line, String[] gffColumns,
306 AlignmentI alignment, Map<String, FeatureColourI> featureColours,
307 boolean removeHTML, boolean relaxedIdMatching,
311 * tokens: description seqid seqIndex start end type [score]
313 if (gffColumns.length < 6)
315 System.err.println("Ignoring feature line '" + line
316 + "' with too few columns (" + gffColumns.length + ")");
319 String desc = gffColumns[0];
320 String seqId = gffColumns[1];
321 SequenceI seq = findSequence(seqId, alignment, null, relaxedIdMatching);
323 if (!ID_NOT_SPECIFIED.equals(seqId))
325 seq = findSequence(seqId, alignment, null, relaxedIdMatching);
331 String seqIndex = gffColumns[2];
334 int idx = Integer.parseInt(seqIndex);
335 seq = alignment.getSequenceAt(idx);
336 } catch (NumberFormatException ex)
338 System.err.println("Invalid sequence index: " + seqIndex);
344 System.out.println("Sequence not found: " + line);
348 int startPos = Integer.parseInt(gffColumns[3]);
349 int endPos = Integer.parseInt(gffColumns[4]);
351 String ft = gffColumns[5];
353 if (!featureColours.containsKey(ft))
356 * Perhaps an old style groups file with no colours -
357 * synthesize a colour from the feature type
359 Color colour = ColorUtils.createColourFromName(ft);
360 featureColours.put(ft, new FeatureColour(colour));
362 SequenceFeature sf = null;
363 if (gffColumns.length > 6)
365 float score = Float.NaN;
368 score = new Float(gffColumns[6]).floatValue();
369 } catch (NumberFormatException ex)
371 sf = new SequenceFeature(ft, desc, startPos, endPos, featureGroup);
373 sf = new SequenceFeature(ft, desc, startPos, endPos, score,
378 sf = new SequenceFeature(ft, desc, startPos, endPos, featureGroup);
381 parseDescriptionHTML(sf, removeHTML);
383 seq.addSequenceFeature(sf);
386 && (seq = alignment.findName(seq, seqId, false)) != null)
388 seq.addSequenceFeature(new SequenceFeature(sf));
394 * clear any temporary handles used to speed up ID matching
396 protected void resetMatcher()
398 lastmatchedAl = null;
403 * Returns a sequence matching the given id, as follows
405 * <li>strict matching is on exact sequence name</li>
406 * <li>relaxed matching allows matching on a token within the sequence name,
408 * <li>first tries to find a match in the alignment sequences</li>
409 * <li>else tries to find a match in the new sequences already generated while
410 * parsing the features file</li>
411 * <li>else creates a new placeholder sequence, adds it to the new sequences
412 * list, and returns it</li>
418 * @param relaxedIdMatching
422 protected SequenceI findSequence(String seqId, AlignmentI align,
423 List<SequenceI> newseqs, boolean relaxedIdMatching)
425 // TODO encapsulate in SequenceIdMatcher, share the matcher
426 // with the GffHelper (removing code duplication)
427 SequenceI match = null;
428 if (relaxedIdMatching)
430 if (lastmatchedAl != align)
432 lastmatchedAl = align;
433 matcher = new SequenceIdMatcher(align.getSequencesArray());
436 matcher.addAll(newseqs);
439 match = matcher.findIdMatch(seqId);
443 match = align.findName(seqId, true);
444 if (match == null && newseqs != null)
446 for (SequenceI m : newseqs)
448 if (seqId.equals(m.getName()))
456 if (match == null && newseqs != null)
458 match = new SequenceDummy(seqId);
459 if (relaxedIdMatching)
461 matcher.addAll(Arrays.asList(new SequenceI[] { match }));
463 // add dummy sequence to the newseqs list
469 public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML)
471 if (sf.getDescription() == null)
475 ParseHtmlBodyAndLinks parsed = new ParseHtmlBodyAndLinks(
476 sf.getDescription(), removeHTML, newline);
480 sf.setDescription(parsed.getNonHtmlContent());
483 for (String link : parsed.getLinks())
490 * Returns contents of a Jalview format features file, for visible features,
491 * as filtered by type and group. Features with a null group are displayed if
492 * their feature type is visible. Non-positional features may optionally be
493 * included (with no check on type or group).
498 * map of colour for each visible feature type
499 * @param visibleFeatureGroups
500 * @param includeNonPositional
501 * if true, include non-positional features (regardless of group or
505 public String printJalviewFormat(SequenceI[] sequences,
506 Map<String, FeatureColourI> visible,
507 List<String> visibleFeatureGroups, boolean includeNonPositional)
509 if (!includeNonPositional && (visible == null || visible.isEmpty()))
511 // no point continuing.
512 return "No Features Visible";
516 * write out feature colours (if we know them)
518 // TODO: decide if feature links should also be written here ?
519 StringBuilder out = new StringBuilder(256);
522 for (Entry<String, FeatureColourI> featureColour : visible.entrySet())
524 FeatureColourI colour = featureColour.getValue();
525 out.append(colour.toJalviewFormat(featureColour.getKey())).append(
530 String[] types = visible == null ? new String[0] : visible.keySet()
531 .toArray(new String[visible.keySet().size()]);
534 * sort groups alphabetically, and ensure that features with a
535 * null or empty group are output after those in named groups
537 List<String> sortedGroups = new ArrayList<String>(visibleFeatureGroups);
538 sortedGroups.remove(null);
539 sortedGroups.remove("");
540 Collections.sort(sortedGroups);
541 sortedGroups.add(null);
542 sortedGroups.add("");
544 boolean foundSome = false;
547 * first output any non-positional features
549 if (includeNonPositional)
551 for (int i = 0; i < sequences.length; i++)
553 String sequenceName = sequences[i].getName();
554 for (SequenceFeature feature : sequences[i].getFeatures()
555 .getNonPositionalFeatures())
558 out.append(formatJalviewFeature(sequenceName, feature));
563 for (String group : sortedGroups)
565 boolean isNamedGroup = (group != null && !"".equals(group));
569 out.append("STARTGROUP").append(TAB);
575 * output positional features within groups
577 for (int i = 0; i < sequences.length; i++)
579 String sequenceName = sequences[i].getName();
580 List<SequenceFeature> features = new ArrayList<SequenceFeature>();
581 if (types.length > 0)
583 features.addAll(sequences[i].getFeatures().getFeaturesForGroup(
584 true, group, types));
587 for (SequenceFeature sequenceFeature : features)
590 out.append(formatJalviewFeature(sequenceName, sequenceFeature));
596 out.append("ENDGROUP").append(TAB);
602 return foundSome ? out.toString() : "No Features Visible";
607 * @param sequenceName
608 * @param sequenceFeature
610 protected String formatJalviewFeature(
611 String sequenceName, SequenceFeature sequenceFeature)
613 StringBuilder out = new StringBuilder(64);
614 if (sequenceFeature.description == null
615 || sequenceFeature.description.equals(""))
617 out.append(sequenceFeature.type).append(TAB);
621 if (sequenceFeature.links != null
622 && sequenceFeature.getDescription().indexOf("<html>") == -1)
624 out.append("<html>");
627 out.append(sequenceFeature.description);
628 if (sequenceFeature.links != null)
630 for (int l = 0; l < sequenceFeature.links.size(); l++)
632 String label = sequenceFeature.links.elementAt(l);
633 String href = label.substring(label.indexOf("|") + 1);
634 label = label.substring(0, label.indexOf("|"));
636 if (sequenceFeature.description.indexOf(href) == -1)
638 out.append(" <a href=\"" + href + "\">" + label + "</a>");
642 if (sequenceFeature.getDescription().indexOf("</html>") == -1)
644 out.append("</html>");
650 out.append(sequenceName);
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);
664 return out.toString();
668 * Parse method that is called when a GFF file is dragged to the desktop
673 AlignViewportI av = getViewport();
676 if (av.getAlignment() != null)
678 dataset = av.getAlignment().getDataset();
682 // working in the applet context ?
683 dataset = av.getAlignment();
688 dataset = new Alignment(new SequenceI[] {});
691 Map<String, FeatureColourI> featureColours = new HashMap<String, FeatureColourI>();
692 boolean parseResult = parse(dataset, featureColours, false, true);
695 // pass error up somehow
699 // update viewport with the dataset data ?
703 setSeqs(dataset.getSequencesArray());
708 * Implementation of unused abstract method
710 * @return error message
713 public String print(SequenceI[] sqs, boolean jvsuffix)
715 System.out.println("Use printGffFormat() or printJalviewFormat()");
720 * Returns features output in GFF2 format
723 * the sequences whose features are to be output
725 * a map whose keys are the type names of visible features
726 * @param visibleFeatureGroups
727 * @param includeNonPositionalFeatures
730 public String printGffFormat(SequenceI[] sequences,
731 Map<String, FeatureColourI> visible,
732 List<String> visibleFeatureGroups,
733 boolean includeNonPositionalFeatures)
735 StringBuilder out = new StringBuilder(256);
737 out.append(String.format("%s %d\n", GFF_VERSION, gffVersion == 0 ? 2 : gffVersion));
739 if (!includeNonPositionalFeatures
740 && (visible == null || visible.isEmpty()))
742 return out.toString();
745 String[] types = visible == null ? new String[0] : visible.keySet()
747 new String[visible.keySet().size()]);
749 for (SequenceI seq : sequences)
751 List<SequenceFeature> features = new ArrayList<SequenceFeature>();
752 if (includeNonPositionalFeatures)
754 features.addAll(seq.getFeatures().getNonPositionalFeatures());
756 if (visible != null && !visible.isEmpty())
758 features.addAll(seq.getFeatures().getPositionalFeatures(types));
761 for (SequenceFeature sf : features)
763 String source = sf.featureGroup;
764 if (!sf.isNonPositional() && source != null
765 && !visibleFeatureGroups.contains(source))
767 // group is not visible
773 source = sf.getDescription();
776 out.append(seq.getName());
782 out.append(sf.begin);
786 out.append(sf.score);
789 int strand = sf.getStrand();
790 out.append(strand == 1 ? "+" : (strand == -1 ? "-" : "."));
793 String phase = sf.getPhase();
794 out.append(phase == null ? "." : phase);
796 // miscellaneous key-values (GFF column 9)
797 String attributes = sf.getAttributes();
798 if (attributes != null)
800 out.append(TAB).append(attributes);
807 return out.toString();
811 * Returns a mapping given list of one or more Align descriptors (exonerate
814 * @param alignedRegions
815 * a list of "Align fromStart toStart fromCount"
816 * @param mapIsFromCdna
817 * if true, 'from' is dna, else 'from' is protein
819 * either 1 (forward) or -1 (reverse)
821 * @throws IOException
823 protected MapList constructCodonMappingFromAlign(
824 List<String> alignedRegions, boolean mapIsFromCdna, int strand)
829 throw new IOException(
830 "Invalid strand for a codon mapping (cannot be 0)");
832 int regions = alignedRegions.size();
833 // arrays to hold [start, end] for each aligned region
834 int[] fromRanges = new int[regions * 2]; // from dna
835 int[] toRanges = new int[regions * 2]; // to protein
836 int fromRangesIndex = 0;
837 int toRangesIndex = 0;
839 for (String range : alignedRegions)
842 * Align mapFromStart mapToStart mapFromCount
843 * e.g. if mapIsFromCdna
844 * Align 11270 143 120
846 * 120 bases from pos 11270 align to pos 143 in peptide
847 * if !mapIsFromCdna this would instead be
850 String[] tokens = range.split(" ");
851 if (tokens.length != 3)
853 throw new IOException("Wrong number of fields for Align");
860 fromStart = Integer.parseInt(tokens[0]);
861 toStart = Integer.parseInt(tokens[1]);
862 fromCount = Integer.parseInt(tokens[2]);
863 } catch (NumberFormatException nfe)
865 throw new IOException(
866 "Invalid number in Align field: " + nfe.getMessage());
870 * Jalview always models from dna to protein, so adjust values if the
871 * GFF mapping is from protein to dna
876 int temp = fromStart;
880 fromRanges[fromRangesIndex++] = fromStart;
881 fromRanges[fromRangesIndex++] = fromStart + strand * (fromCount - 1);
884 * If a codon has an intron gap, there will be contiguous 'toRanges';
885 * this is handled for us by the MapList constructor.
886 * (It is not clear that exonerate ever generates this case)
888 toRanges[toRangesIndex++] = toStart;
889 toRanges[toRangesIndex++] = toStart + (fromCount - 1) / 3;
892 return new MapList(fromRanges, toRanges, 3, 1);
896 * Parse a GFF format feature. This may include creating a 'dummy' sequence to
897 * hold the feature, or for its mapped sequence, or both, to be resolved
898 * either later in the GFF file (##FASTA section), or when the user loads
899 * additional sequences.
903 * @param relaxedIdMatching
907 protected SequenceI parseGff(String[] gffColumns, AlignmentI alignment,
908 boolean relaxedIdMatching, List<SequenceI> newseqs)
911 * GFF: seqid source type start end score strand phase [attributes]
913 if (gffColumns.length < 5)
915 System.err.println("Ignoring GFF feature line with too few columns ("
916 + gffColumns.length + ")");
921 * locate referenced sequence in alignment _or_
922 * as a forward or external reference (SequenceDummy)
924 String seqId = gffColumns[0];
925 SequenceI seq = findSequence(seqId, alignment, newseqs,
928 SequenceFeature sf = null;
929 GffHelperI helper = GffHelperFactory.getHelper(gffColumns);
934 sf = helper.processGff(seq, gffColumns, alignment, newseqs,
938 seq.addSequenceFeature(sf);
939 while ((seq = alignment.findName(seq, seqId, true)) != null)
941 seq.addSequenceFeature(new SequenceFeature(sf));
944 } catch (IOException e)
946 System.err.println("GFF parsing failed with: " + e.getMessage());
955 * Process the 'column 9' data of the GFF file. This is less formally defined,
956 * and its interpretation will vary depending on the tool that has generated
962 protected void processGffColumnNine(String attributes, SequenceFeature sf)
964 sf.setAttributes(attributes);
967 * Parse attributes in column 9 and add them to the sequence feature's
968 * 'otherData' table; use Note as a best proxy for description
970 char nameValueSeparator = gffVersion == 3 ? '=' : ' ';
971 // TODO check we don't break GFF2 values which include commas here
972 Map<String, List<String>> nameValues = GffHelperBase
973 .parseNameValuePairs(attributes, ";", nameValueSeparator, ",");
974 for (Entry<String, List<String>> attr : nameValues.entrySet())
976 String values = StringUtils.listToDelimitedString(attr.getValue(),
978 sf.setValue(attr.getKey(), values);
979 if (NOTE.equals(attr.getKey()))
981 sf.setDescription(values);
987 * After encountering ##fasta in a GFF3 file, process the remainder of the
988 * file as FAST sequence data. Any placeholder sequences created during
989 * feature parsing are updated with the actual sequences.
993 * @throws IOException
995 protected void processAsFasta(AlignmentI align, List<SequenceI> newseqs)
1001 } catch (IOException q)
1004 FastaFile parser = new FastaFile(this);
1005 List<SequenceI> includedseqs = parser.getSeqs();
1007 SequenceIdMatcher smatcher = new SequenceIdMatcher(newseqs);
1010 * iterate over includedseqs, and replacing matching ones with newseqs
1011 * sequences. Generic iterator not used here because we modify
1012 * includedseqs as we go
1014 for (int p = 0, pSize = includedseqs.size(); p < pSize; p++)
1016 // search for any dummy seqs that this sequence can be used to update
1017 SequenceI includedSeq = includedseqs.get(p);
1018 SequenceI dummyseq = smatcher.findIdMatch(includedSeq);
1019 if (dummyseq != null && dummyseq instanceof SequenceDummy)
1021 // probably have the pattern wrong
1022 // idea is that a flyweight proxy for a sequence ID can be created for
1023 // 1. stable reference creation
1024 // 2. addition of annotation
1025 // 3. future replacement by a real sequence
1026 // current pattern is to create SequenceDummy objects - a convenience
1027 // constructor for a Sequence.
1028 // problem is that when promoted to a real sequence, all references
1029 // need to be updated somehow. We avoid that by keeping the same object.
1030 ((SequenceDummy) dummyseq).become(includedSeq);
1031 dummyseq.createDatasetSequence();
1034 * Update mappings so they are now to the dataset sequence
1036 for (AlignedCodonFrame mapping : align.getCodonFrames())
1038 mapping.updateToDataset(dummyseq);
1042 * replace parsed sequence with the realised forward reference
1044 includedseqs.set(p, dummyseq);
1047 * and remove from the newseqs list
1049 newseqs.remove(dummyseq);
1054 * finally add sequences to the dataset
1056 for (SequenceI seq : includedseqs)
1058 // experimental: mapping-based 'alignment' to query sequence
1059 AlignmentUtils.alignSequenceAs(seq, align,
1060 String.valueOf(align.getGapCharacter()), false, true);
1062 // rename sequences if GFF handler requested this
1063 // TODO a more elegant way e.g. gffHelper.postProcess(newseqs) ?
1064 List<SequenceFeature> sfs = seq.getFeatures().getPositionalFeatures();
1067 String newName = (String) sfs.get(0).getValue(
1068 GffHelperI.RENAME_TOKEN);
1069 if (newName != null)
1071 seq.setName(newName);
1074 align.addSequence(seq);
1079 * Process a ## directive
1085 * @throws IOException
1087 protected void processGffPragma(String line, Map<String, String> gffProps,
1088 AlignmentI align, List<SequenceI> newseqs) throws IOException
1091 if ("###".equals(line))
1093 // close off any open 'forward references'
1097 String[] tokens = line.substring(2).split(" ");
1098 String pragma = tokens[0];
1099 String value = tokens.length == 1 ? null : tokens[1];
1101 if ("gff-version".equalsIgnoreCase(pragma))
1107 // value may be e.g. "3.1.2"
1108 gffVersion = Integer.parseInt(value.split("\\.")[0]);
1109 } catch (NumberFormatException e)
1115 else if ("sequence-region".equalsIgnoreCase(pragma))
1117 // could capture <seqid start end> if wanted here
1119 else if ("feature-ontology".equalsIgnoreCase(pragma))
1121 // should resolve against the specified feature ontology URI
1123 else if ("attribute-ontology".equalsIgnoreCase(pragma))
1125 // URI of attribute ontology - not currently used in GFF3
1127 else if ("source-ontology".equalsIgnoreCase(pragma))
1129 // URI of source ontology - not currently used in GFF3
1131 else if ("species-build".equalsIgnoreCase(pragma))
1133 // save URI of specific NCBI taxon version of annotations
1134 gffProps.put("species-build", value);
1136 else if ("fasta".equalsIgnoreCase(pragma))
1138 // process the rest of the file as a fasta file and replace any dummy
1140 processAsFasta(align, newseqs);
1144 System.err.println("Ignoring unknown pragma: " + line);