X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFeaturesFile.java;h=c6bc1dd2354890cffd597c7630ac04b67f60211a;hb=c75ca41e87495a7d86ebc3c8cbeb56610ac48758;hp=d6c3c21d8386670f7d0a7981f99c6ba83a799843;hpb=96b4831c8077728623cb84cfd6940ac5b37df2c4;p=jalview.git diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index d6c3c21..c6bc1dd 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -70,27 +70,48 @@ public class FeaturesFile extends AlignFile } /** - * Creates a new FeaturesFile object. - * * @param inFile - * DOCUMENT ME! * @param type - * DOCUMENT ME! - * * @throws IOException - * DOCUMENT ME! */ public FeaturesFile(String inFile, String type) throws IOException { super(inFile, type); } + /** + * @param source + * @throws IOException + */ public FeaturesFile(FileParse source) throws IOException { super(source); } /** + * @param parseImmediately + * @param source + * @throws IOException + */ + public FeaturesFile(boolean parseImmediately, FileParse source) + throws IOException + { + super(parseImmediately, source); + } + + /** + * @param parseImmediately + * @param inFile + * @param type + * @throws IOException + */ + public FeaturesFile(boolean parseImmediately, String inFile, String type) + throws IOException + { + super(parseImmediately, inFile, type); + } + + /** * Parse GFF or sequence features file using case-independent matching, * discarding URLs * @@ -102,8 +123,7 @@ public class FeaturesFile extends AlignFile * - process html strings into plain text * @return true if features were added */ - public boolean parse(AlignmentI align, Hashtable colours, - boolean removeHTML) + public boolean parse(AlignmentI align, Map colours, boolean removeHTML) { return parse(align, colours, null, removeHTML, false); } @@ -148,6 +168,24 @@ public class FeaturesFile extends AlignFile return parse(align, colours, featureLink, removeHTML, false); } + @Override + public void addAnnotations(AlignmentI al) + { + super.addAnnotations(al); + } + + @Override + public void addProperties(AlignmentI al) + { + super.addProperties(al); + } + + @Override + public void addSeqGroups(AlignmentI al) + { + super.addSeqGroups(al); + } + /** * Parse GFF or sequence features file * @@ -172,7 +210,8 @@ public class FeaturesFile extends AlignFile { SequenceI seq = null; /** - * keep track of any sequences we try to create from the data if it is a GFF3 file + * keep track of any sequences we try to create from the data if it is a + * GFF3 file */ ArrayList newseqs = new ArrayList(); String type, desc, token = null; @@ -791,18 +830,19 @@ public class FeaturesFile extends AlignFile * @return true if sf was actually added to the sequence, false if it was * processed in another way */ - public boolean processOrAddSeqFeature(AlignmentI align, List newseqs, SequenceI seq, SequenceFeature sf, + public boolean processOrAddSeqFeature(AlignmentI align, + List newseqs, SequenceI seq, SequenceFeature sf, boolean gFFFile, boolean relaxedIdMatching) { String attr = (String) sf.getValue("ATTRIBUTES"); boolean add = true; if (gFFFile && attr != null) { - int nattr=8; + int nattr = 8; for (String attset : attr.split("\t")) { - if (attset==null || attset.trim().length()==0) + if (attset == null || attset.trim().length() == 0) { continue; } @@ -818,22 +858,25 @@ public class FeaturesFile extends AlignFile continue; } - // expect either space seperated (gff2) or '=' separated (gff3) + // expect either space seperated (gff2) or '=' separated (gff3) // key/value pairs here - int eqpos = pair.indexOf('='),sppos = pair.indexOf(' '); + int eqpos = pair.indexOf('='), sppos = pair.indexOf(' '); String key = null, value = null; if (sppos > -1 && (eqpos == -1 || sppos < eqpos)) { key = pair.substring(0, sppos); value = pair.substring(sppos + 1); - } else { + } + else + { if (eqpos > -1 && (sppos == -1 || eqpos < sppos)) { key = pair.substring(0, eqpos); value = pair.substring(eqpos + 1); - } else + } + else { key = pair; } @@ -856,8 +899,8 @@ public class FeaturesFile extends AlignFile { add &= processGffKey(set, nattr, seq, sf, align, newseqs, relaxedIdMatching); // process decides if - // feature is actually - // added + // feature is actually + // added } catch (InvalidGFF3FieldException ivfe) { System.err.println(ivfe); @@ -906,20 +949,20 @@ public class FeaturesFile extends AlignFile { int strand = sf.getStrand(); // exonerate cdna/protein map - // look for fields + // look for fields List querySeq = findNames(align, newseqs, - relaxedIdMatching, set.get(attr="Query")); - if (querySeq==null || querySeq.size()!=1) + relaxedIdMatching, set.get(attr = "Query")); + if (querySeq == null || querySeq.size() != 1) { - throw new InvalidGFF3FieldException( attr, set, + throw new InvalidGFF3FieldException(attr, set, "Expecting exactly one sequence in Query field (got " + set.get(attr) + ")"); } - if (set.containsKey(attr="Align")) + if (set.containsKey(attr = "Align")) { // process the align maps and create cdna/protein maps // ideally, the query sequences are in the alignment, but maybe not... - + AlignedCodonFrame alco = new AlignedCodonFrame(); MapList codonmapping = constructCodonMappingFromAlign(set, attr, strand); @@ -937,8 +980,8 @@ public class FeaturesFile extends AlignFile } private MapList constructCodonMappingFromAlign( - Map> set, - String attr, int strand) throws InvalidGFF3FieldException + Map> set, String attr, int strand) + throws InvalidGFF3FieldException { if (strand == 0) { @@ -1092,21 +1135,21 @@ public class FeaturesFile extends AlignFile } } } - + } - if (match==null && newseqs!=null) + if (match == null && newseqs != null) { match = new SequenceDummy(seqId); if (relaxedIdMatching) { - matcher.addAll(Arrays.asList(new SequenceI[] - { match })); + matcher.addAll(Arrays.asList(new SequenceI[] { match })); } // add dummy sequence to the newseqs list newseqs.add(match); } return match; } + public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML) { if (sf.getDescription() == null) @@ -1134,7 +1177,8 @@ public class FeaturesFile extends AlignFile * hash of feature types and colours * @return features file contents */ - public String printJalviewFormat(SequenceI[] seqs, Map visible) + public String printJalviewFormat(SequenceI[] seqs, + Map visible) { return printJalviewFormat(seqs, visible, true, true); } @@ -1342,7 +1386,7 @@ public class FeaturesFile extends AlignFile out.append(next[j].end); out.append("\t"); out.append(next[j].type); - if (next[j].score != Float.NaN) + if (!Float.isNaN(next[j].score)) { out.append("\t"); out.append(next[j].score); @@ -1382,13 +1426,13 @@ public class FeaturesFile extends AlignFile * @param visible * @return */ - public String printGFFFormat(SequenceI[] seqs, Map visible) + public String printGFFFormat(SequenceI[] seqs, Map visible) { return printGFFFormat(seqs, visible, true, true); } - public String printGFFFormat(SequenceI[] seqs, Map visible, - boolean visOnly, boolean nonpos) + public String printGFFFormat(SequenceI[] seqs, + Map visible, boolean visOnly, boolean nonpos) { StringBuffer out = new StringBuffer(); SequenceFeature[] next;