*This version resolves references to Sequence objects from AlignmentSequence
*TODO: Define info: urn for dictionary string (could also be regex of valid characters!)
* @param s
+ * @param dict TODO
* @return true if a valid amino acid sequence object
*/
- private static boolean valid_aadictionary_string(String s) {
+ private static boolean valid_aadictionary_string(String s, String dict) {
if (s==null)
return false;
// validate against dictionary
String remnants = aa_repl.matcher(s).replaceAll("");
return !remnants.matches("//S+");
}
-
+
+ public static Sequence newSequence(String Name, String Sequence, String Dictionary, int start, int end) {
+ //TODO: make hierarchy reflecting the SeqType object.
+ Sequence seq= new Sequence();
+ seq.setDictionary(Dictionary);
+ seq.setName(Name);
+ seq.setSequence(Sequence);
+ seq.setStart(start);
+ if (start<=end) {
+ if ((end-start)!=Sequence.length())
+ seq.setEnd(start+Sequence.length());
+ } else {
+ // reverse topology mapping. TODO: VAMSAS: decide if allowed to do start>end on Sequence object
+ if ((start-end)!=Sequence.length())
+ seq.setEnd(end+Sequence.length());
+ }
+ return seq;
+ }
+
public static boolean is_valid_aa_seq(SequenceType s) {
Sequence q;
boolean validref=false;
if (q.getDictionary()!=null
&& q.getDictionary().length()>0
- || !q.getDictionary().equals("info:iubmb.org/aminoacid"))
+ || !q.getDictionary().equals(SymbolDictionary.STANDARD_AA))
return false;
- return valid_aadictionary_string(q.getSequence());
+ return valid_aadictionary_string(q.getSequence(), SymbolDictionary.STANDARD_AA);
}
// follow references
Object w = (((AlignmentSequence) s).getRefid());
if (w!=null && w!=s && w instanceof SequenceType)
return is_valid_aa_seq((SequenceType) w)
- && valid_aadictionary_string(((AlignmentSequence) s).getSequence());
+ && valid_aadictionary_string(((AlignmentSequence) s).getSequence(), SymbolDictionary.STANDARD_AA);
}
return false;