From: Mark G. <mg...@us...> - 2003-07-08 20:01:00
|
Update of /cvsroot/gmod/apollo/src/java/apollo/datamodel In directory sc8-pr-cvs1:/tmp/cvs-serv9808/src/java/apollo/datamodel Modified Files: FeaturePair.java Log Message: FeaturePair now looks for an explicitly set query and hit alignment (set in the alignment property of the query and hit features) before looking for cigars. This allows features with hit and query alignments (the verbose equivalent of a cigar) but no cigar to come up in jalview. There are features that have their query alignments as peptides. This brings up issues which ill email about. Index: FeaturePair.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/datamodel/FeaturePair.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** FeaturePair.java 11 Jun 2003 15:57:22 -0000 1.25 --- FeaturePair.java 8 Jul 2003 20:00:57 -0000 1.26 *************** *** 12,17 **** SeqFeatureI hit; ! StringBuffer q_alignment; ! StringBuffer h_alignment; // M == match // D == delete --- 12,19 ---- SeqFeatureI hit; ! //StringBuffer q_alignment; ! private String queryAlignment; ! //StringBuffer h_alignment; ! private String hitAlignment; // M == match // D == delete *************** *** 24,28 **** /* Don't use the above, if the sequence is needed then get the real thing from the FeatureSet holding this FeaturePair */ ! String cigar = ""; /** f1 is query feature, f2 is hit feature */ --- 26,30 ---- /* Don't use the above, if the sequence is needed then get the real thing from the FeatureSet holding this FeaturePair */ ! String cigar = ""; // why "" and not null? /** f1 is query feature, f2 is hit feature */ *************** *** 221,229 **** public boolean hasAlignmentSequence() { ! String alignment = hit.getResidues(); // Right now jalview only jibing with cigars - eventually get it working with // alignments as well - needs work //if (alignment.equals("")) alignment = hit.getProperty("alignment"); ! return (!alignment.equals("") && hasCigar()); } --- 223,233 ---- public boolean hasAlignmentSequence() { ! // I think this is wrong - dont we care about align seq, not hit residues? ! //String alignment = hit.getResidues(); // Right now jalview only jibing with cigars - eventually get it working with // alignments as well - needs work //if (alignment.equals("")) alignment = hit.getProperty("alignment"); ! //return (!alignment.equals("") && hasCigar()); ! return hasAlignable(); } *************** *** 353,378 **** } ! private boolean hasCigar() { return cigar != null; } public String getHitAlignment () { ! if (h_alignment == null) { ! String alignment = hit.getResidues(); ! if (!alignment.equals("")) ! parseCigar(); else ! h_alignment = new StringBuffer(hit.getProperty("alignment")); } ! return h_alignment.toString(); } public String getRefAlignment () { ! if (q_alignment == null) { ! parseCigar(); } ! return q_alignment.toString(); } ! protected void parseCigar() { ! StringTokenizer cigarTokens = new StringTokenizer(getCigar(), cigarDelims, true); --- 357,400 ---- } ! private boolean hasCigar() { return !isEmptyOrNull(cigar); } + /** From Alignable interface. Returns alignment string for hit, with dashes + for gaps. */ public String getHitAlignment () { ! if (hitAlignment == null) { ! // Check if hit alignment given explicitly ! String explicitAlignment = hit.getProperty("alignment"); ! if (!isEmptyOrNull(explicitAlignment)) ! hitAlignment = explicitAlignment; else ! parseCigar(); // sets hitAlignment } ! return hitAlignment; } public String getRefAlignment () { ! if (queryAlignment == null) { ! // check if query alignment set as a property ! String explicitAlignment = query.getProperty("alignment"); ! if (!isEmptyOrNull(explicitAlignment)) ! queryAlignment = explicitAlignment; ! else ! parseCigar(); // sets queryAlignment } ! return queryAlignment; ! } ! ! private boolean isEmptyOrNull(String s) { ! if (s==null) return true; ! return s.equals(""); } ! /** Populates hitAlignment and queryAlignment using cigar string and hit and ! query seqs */ ! private void parseCigar() { ! if (!hasCigar()) return; ! if (isEmptyOrNull(getResidues())) return; ! if (isEmptyOrNull(getHitFeature().getResidues())) return; ! StringTokenizer cigarTokens = new StringTokenizer(getCigar(), cigarDelims, true); *************** *** 381,386 **** String q_seq = getResidues(); String h_seq = getHitFeature().getResidues(); ! q_alignment = new StringBuffer(); ! h_alignment = new StringBuffer(); // units indicates whether to count by one (for DNA bases) or // to count by 3 (for AA) --- 403,408 ---- String q_seq = getResidues(); String h_seq = getHitFeature().getResidues(); ! StringBuffer q_alignment = new StringBuffer(); ! StringBuffer h_alignment = new StringBuffer(); // units indicates whether to count by one (for DNA bases) or // to count by 3 (for AA) *************** *** 442,448 **** type = next_type; } } ! protected String appendAlignment (StringBuffer alignment, String seq, int length, --- 464,472 ---- type = next_type; } + queryAlignment = q_alignment.toString(); + hitAlignment = h_alignment.toString(); } ! private String appendAlignment (StringBuffer alignment, String seq, int length, *************** *** 468,472 **** /** Should this only return true if this FeaturePair has the means of making an alignment - might be handier that way. */ ! public boolean hasAlignable() { return getRefAlignment()!=null; } /** If hasAlignable is false returns null. Otherwise returns this. */ public Alignable getAlignable() { --- 492,499 ---- /** Should this only return true if this FeaturePair has the means of making an alignment - might be handier that way. */ ! public boolean hasAlignable() { ! // Also check for !.equals""? ! return getRefAlignment()!=null && getHitAlignment()!=null; ! } /** If hasAlignable is false returns null. Otherwise returns this. */ public Alignable getAlignable() { |