<commit_before><commit_msg>Some usefull things to do with annotations.<commit_after>package org.biojava.bio;

import java.util.*;
import org.biojava.utils.*;

public final class AnnotationTools {
  public static Annotation allIn(Annotation annotation, AnnotationType annType) {
    Annotation res;
    if(annotation instanceof SmallAnnotation) {
      res = new SmallAnnotation();
    } else {
      res = new SimpleAnnotation();
    }
    
    for(Iterator i = annType.getProperties().iterator(); i.hasNext(); ) {
      Object tag = i.next();
      try {
        res.setProperty(tag, annotation.getProperty(tag));
      } catch (ChangeVetoException cve) {
        throw new BioError(cve, "Assertion Failure: Can't alter an annotatoin");
      }
    }
    
    return res;
  }
  
  public static Annotation allOut(Annotation annotation, AnnotationType annType) {
    Annotation res;
    if(annotation instanceof SmallAnnotation) {
      res = new SmallAnnotation();
    } else {
      res = new SimpleAnnotation();
    }
    
    Set props = annType.getProperties();
    for(Iterator i = annotation.keys().iterator(); i.hasNext(); ) {
      Object tag = i.next();
      if(!props.contains(tag)) {
        try {
          res.setProperty(tag, annotation.getProperty(tag));
        } catch (ChangeVetoException cve) {
          throw new BioError(cve, "Assertion Failure: Can't alter an annotatoin");
        }
      }
    }
    
    return res;
  }
}
{'fraction_non_alphanumeric': 0.11180124223602485, 'fraction_numerical': 0.0, 'mean_word_length': 2.756476683937824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6122262', 'n_tokens_mistral': 421, 'n_tokens_neox': 409, 'n_words': 106}