*/
package jalview.io;
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-
import jalview.analysis.SecStrConsensus.SimpleBP;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceI;
import jalview.util.MessageManager;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import com.stevesoft.pat.Regex;
+
import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
import fr.orsay.lri.varna.exceptions.ExceptionLoadingFailed;
import fr.orsay.lri.varna.exceptions.ExceptionPermissionDenied;
int end = seq.length();
id = current.getName();
+ if (id == null || id.trim().length() == 0)
+ {
+ id = safeName(getDataName());
+ if (result.size() > 1)
+ {
+ id += "." + i;
+ }
+ }
seqs[i] = new Sequence(id, seq, begin, end);
seqs[i].setEnd(seqs[i].findPosition(seqs[i].getLength()));
private String safeName(String dataName)
{
int b = 0;
- while ((b = dataName.indexOf("/")) > -1 && b < dataName.length())
+ if ((b = dataName.lastIndexOf(".")) > 0)
{
- dataName = dataName.substring(b + 1).trim();
-
+ dataName = dataName.substring(0, b - 1);
+ }
+ b = 0;
+ Regex m = new Regex("[\\/]?([-A-Za-z0-9]+)\\.?");
+ String mm = dataName;
+ while (m.searchFrom(dataName, b))
+ {
+ mm = m.stringMatched();
+ b = m.matchedTo();
}
- int e = (dataName.length() - dataName.indexOf(".")) + 1;
- dataName = dataName.substring(1, e).trim();
- return dataName;
+ return mm;
}
}