X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFeaturesFile.java;h=4be8d0e37e321bd678d01f562070f8db5408f48d;hb=3d0101179759ef157b088ea135423cd909512d9f;hp=73783e5b408a0dac903dabe9d10d480626651a16;hpb=37de9310bec3501cbc6381e0c3dcb282fcaad812;p=jalview.git diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 73783e5..4be8d0e 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -35,11 +35,12 @@ import jalview.io.gff.GffHelperBase; import jalview.io.gff.GffHelperFactory; import jalview.io.gff.GffHelperI; import jalview.schemes.FeatureColour; -import jalview.schemes.UserColourScheme; +import jalview.util.ColorUtils; import jalview.util.MapList; import jalview.util.ParseHtmlBodyAndLinks; import jalview.util.StringUtils; +import java.awt.Color; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -94,12 +95,13 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * Constructor which does not parse the file immediately * * @param inFile - * @param type + * @param paste * @throws IOException */ - public FeaturesFile(String inFile, String type) throws IOException + public FeaturesFile(String inFile, DataSourceType paste) + throws IOException { - super(false, inFile, type); + super(false, inFile, paste); } /** @@ -119,8 +121,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * @param type * @throws IOException */ - public FeaturesFile(boolean parseImmediately, String inFile, String type) - throws IOException + public FeaturesFile(boolean parseImmediately, String inFile, + DataSourceType type) throws IOException { super(parseImmediately, inFile, type); } @@ -302,7 +304,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI */ protected boolean parseJalviewFeature(String line, String[] gffColumns, AlignmentI alignment, Map featureColours, - boolean removeHTML, boolean relaxedIdMatching, String featureGroup) + boolean removeHTML, boolean relaxedIdMatching, + String featureGroup) { /* * tokens: description seqid seqIndex start end type [score] @@ -353,11 +356,11 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * Perhaps an old style groups file with no colours - * synthesize a colour from the feature type */ - UserColourScheme ucs = new UserColourScheme(ft); - featureColours.put(ft, new FeatureColour(ucs.findColour('A'))); + Color colour = ColorUtils.createColourFromName(ft); + featureColours.put(ft, new FeatureColour(colour)); } - SequenceFeature sf = new SequenceFeature(ft, desc, "", startPos, - endPos, featureGroup); + SequenceFeature sf = new SequenceFeature(ft, desc, "", startPos, endPos, + featureGroup); if (gffColumns.length > 6) { float score = Float.NaN; @@ -547,9 +550,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI for (int j = 0; j < features.length; j++) { isnonpos = features[j].begin == 0 && features[j].end == 0; - if ((!nonpos && isnonpos) - || (!isnonpos && visOnly && !visible - .containsKey(features[j].type))) + if ((!nonpos && isnonpos) || (!isnonpos && visOnly + && !visible.containsKey(features[j].type))) { continue; } @@ -588,18 +590,16 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI { isnonpos = sequenceFeature.begin == 0 && sequenceFeature.end == 0; - if ((!nonpos && isnonpos) - || (!isnonpos && visOnly && !visible - .containsKey(sequenceFeature.type))) + if ((!nonpos && isnonpos) || (!isnonpos && visOnly + && !visible.containsKey(sequenceFeature.type))) { // skip if feature is nonpos and we ignore them or if we only // output visible and it isn't non-pos and it's not visible continue; } - if (group != null - && (sequenceFeature.featureGroup == null || !sequenceFeature.featureGroup - .equals(group))) + if (group != null && (sequenceFeature.featureGroup == null + || !sequenceFeature.featureGroup.equals(group))) { continue; } @@ -617,8 +617,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } else { - if (sequenceFeature.links != null - && sequenceFeature.getDescription().indexOf("") == -1) + if (sequenceFeature.links != null && sequenceFeature + .getDescription().indexOf("") == -1) { out.append(""); } @@ -634,12 +634,13 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI if (sequenceFeature.description.indexOf(href) == -1) { - out.append(" " + label - + ""); + out.append( + " " + label + ""); } } - if (sequenceFeature.getDescription().indexOf("") == -1) + if (sequenceFeature.getDescription() + .indexOf("") == -1) { out.append(""); } @@ -710,7 +711,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI dataset = new Alignment(new SequenceI[] {}); } - boolean parseResult = parse(dataset, null, false, true); + Map featureColours = new HashMap(); + boolean parseResult = parse(dataset, featureColours, false, true); if (!parseResult) { // pass error up somehow @@ -731,9 +733,10 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * @return error message */ @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { - return "Use printGffFormat() or printJalviewFormat()"; + System.out.println("Use printGffFormat() or printJalviewFormat()"); + return null; } /** @@ -894,8 +897,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI fromCount = Integer.parseInt(tokens[2]); } catch (NumberFormatException nfe) { - throw new IOException("Invalid number in Align field: " - + nfe.getMessage()); + throw new IOException( + "Invalid number in Align field: " + nfe.getMessage()); } /* @@ -1115,9 +1118,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * @param newseqs * @throws IOException */ - protected void processGffPragma(String line, - Map gffProps, AlignmentI align, - List newseqs) throws IOException + protected void processGffPragma(String line, Map gffProps, + AlignmentI align, List newseqs) throws IOException { line = line.trim(); if ("###".equals(line))