/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.io;
-import java.io.*;
-import java.util.*;
-
import jalview.analysis.SequenceIdMatcher;
-import jalview.datamodel.*;
-import jalview.schemes.*;
+import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceDummy;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
+import jalview.schemes.AnnotationColourGradient;
+import jalview.schemes.GraduatedColor;
+import jalview.schemes.UserColourScheme;
import jalview.util.Format;
+import jalview.util.MapList;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
/**
* Parse and create Jalview Features files Detects GFF format features files and
try
{
SequenceI seq = null;
+ /**
+ * keep track of any sequences we try to create from the data if it is a GFF3 file
+ */
+ ArrayList<SequenceI> newseqs = new ArrayList<SequenceI>();
String type, desc, token = null;
int index, start, end;
// Still possible this is an old Jalview file,
// which does not have type colours at the beginning
seqId = token = st.nextToken();
- seq = findName(align, seqId, relaxedIdmatching);
+ seq = findName(align, seqId, relaxedIdmatching, newseqs);
if (seq != null)
{
desc = st.nextToken();
if (st.hasMoreTokens())
{
StringBuffer attributes = new StringBuffer();
+ boolean sep = false;
while (st.hasMoreTokens())
{
- attributes.append("\t" + st.nextElement());
+ attributes.append((sep ? "\t" : "") + st.nextElement());
+ sep = true;
}
// TODO validate and split GFF2 attributes field ? parse out
// ([A-Za-z][A-Za-z0-9_]*) <value> ; and add as
if (!token.equals("ID_NOT_SPECIFIED"))
{
- seq = findName(align, seqId = token, relaxedIdmatching);
+ seq = findName(align, seqId = token, relaxedIdmatching, null);
st.nextToken();
}
else
}
private SequenceI findName(AlignmentI align, String seqId,
- boolean relaxedIdMatching)
+ boolean relaxedIdMatching, List<SequenceI> newseqs)
{
SequenceI match = null;
if (relaxedIdMatching)
{
matcher = new SequenceIdMatcher(
(lastmatchedAl = align).getSequencesArray());
+ if (newseqs != null)
+ {
+ matcher.addAll(newseqs);
+ }
}
match = matcher.findIdMatch(seqId);
}
else
{
match = align.findName(seqId, true);
+
+ }
+ if (match==null && newseqs!=null)
+ {
+ match = new SequenceDummy(seqId);
+ if (relaxedIdMatching)
+ {
+ matcher.addAll(Arrays.asList(new SequenceI[]
+ { match }));
+ }
}
return match;
}
-
public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML)
{
if (sf.getDescription() == null)
* hash of feature types and colours
* @return features file contents
*/
- public String printJalviewFormat(SequenceI[] seqs, Hashtable visible)
+ public String printJalviewFormat(SequenceI[] seqs, Map<String,Object> visible)
{
return printJalviewFormat(seqs, visible, true, true);
}
* of group or type)
* @return features file contents
*/
- public String printJalviewFormat(SequenceI[] seqs, Hashtable visible,
+ public String printJalviewFormat(SequenceI[] seqs, Map visible,
boolean visOnly, boolean nonpos)
{
StringBuffer out = new StringBuffer();
// write feature colours only if we're given them and we are generating
// viewed features
// TODO: decide if feature links should also be written here ?
- Enumeration en = visible.keys();
+ Iterator en = visible.keySet().iterator();
String type, color;
- while (en.hasMoreElements())
+ while (en.hasNext())
{
- type = en.nextElement().toString();
+ type = en.next().toString();
if (visible.get(type) instanceof GraduatedColor)
{
* @param visible
* @return
*/
- public String printGFFFormat(SequenceI[] seqs, Hashtable visible)
+ public String printGFFFormat(SequenceI[] seqs, Map<String,Object> visible)
{
return printGFFFormat(seqs, visible, true, true);
}
- public String printGFFFormat(SequenceI[] seqs, Hashtable visible,
+ public String printGFFFormat(SequenceI[] seqs, Map<String,Object> visible,
boolean visOnly, boolean nonpos)
{
StringBuffer out = new StringBuffer();