<commit_before>package org.ms2ms.data.ms;

import org.ms2ms.Disposable;
import org.ms2ms.utils.Strs;
import org.ms2ms.utils.Tools;

/**
 * Created by yuw on 8/4/16.
 */
public class FragmentEntry implements Comparable<FragmentEntry>, Disposable
{
  private int   mLength;
  private int  mPeptideKey;
  private float mMH;
  private FragmentEntry mPrev;

  public FragmentEntry() { super(); }
  public FragmentEntry(FragmentEntry s)
  {
    super();
    mLength=s.mLength; mPeptideKey=s.mPeptideKey; mMH=s.mMH; mPrev=s.mPrev;
  }
  public FragmentEntry(Float mh, int peptide, FragmentEntry prev, int len)
  {
    super();
    mMH=mh; mPeptideKey=peptide; mPrev=prev; mLength=len;
  }

  public int           getLength()     { return mLength; }
  public Float         getMH()         { return mMH; }
  public Integer       getPeptideKey() { return mPeptideKey; }
  public FragmentEntry getPrev()       { return mPrev; }

  public FragmentEntry setPeptideKey(Integer s)
  {
    mPeptideKey=s;
    return this;
  }
  public FragmentEntry setLen(int s)   { mLength=s; return this; }

  public FragmentEntry copy()
  {
    return new FragmentEntry(mMH, mPeptideKey, mPrev, mLength);
  }
  @Override
  public int compareTo(FragmentEntry o)
  {
    int c = Long.compare(mPeptideKey, o.getPeptideKey());
    if (c==0) c = Integer.compare(mLength, o.getLength());

    return c;
  }

  @Override
  public String toString()
  {
    return mPeptideKey+":"+mLength+"#"+ (Tools.d2s(mMH, 4))+"<-"+(mPrev!=null?Tools.d2s(mPrev.getMH(), 4):"NUL");
  }

  @Override
  public void dispose() { mPrev=null; }
}<commit_msg>RC20170221<commit_after>package org.ms2ms.data.ms;

import org.ms2ms.Disposable;
import org.ms2ms.data.Binary;
import org.ms2ms.utils.IOs;
import org.ms2ms.utils.Strs;
import org.ms2ms.utils.Tools;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by yuw on 8/4/16.
 */
public class FragmentEntry implements Comparable<FragmentEntry>, Disposable, Binary
{
  private int   mLength;
  private int  mPeptideKey;
  private float mMH;
  private FragmentEntry mPrev;

  public FragmentEntry() { super(); }
  public FragmentEntry(FragmentEntry s)
  {
    super();
    mLength=s.mLength; mPeptideKey=s.mPeptideKey; mMH=s.mMH; mPrev=s.mPrev;
  }
  public FragmentEntry(Float mh, int peptide, FragmentEntry prev, int len)
  {
    super();
    mMH=mh; mPeptideKey=peptide; mPrev=prev; mLength=len;
  }

  public int           getLength()     { return mLength; }
  public Float         getMH()         { return mMH; }
  public Integer       getPeptideKey() { return mPeptideKey; }
  public FragmentEntry getPrev()       { return mPrev; }

  public FragmentEntry setPeptideKey(Integer s)
  {
    mPeptideKey=s;
    return this;
  }
  public FragmentEntry setLen(int s)   { mLength=s; return this; }

  public FragmentEntry copy()
  {
    return new FragmentEntry(mMH, mPeptideKey, mPrev, mLength);
  }
  @Override
  public int compareTo(FragmentEntry o)
  {
    int c = Long.compare(mPeptideKey, o.getPeptideKey());
    if (c==0) c = Integer.compare(mLength, o.getLength());

    return c;
  }

  @Override
  public String toString()
  {
    return mPeptideKey+":"+mLength+"#"+ (Tools.d2s(mMH, 4))+"<-"+(mPrev!=null?Tools.d2s(mPrev.getMH(), 4):"NUL");
  }

  @Override
  public void dispose() { mPrev=null; }

  @Override
  public void write(DataOutput ds) throws IOException
  {
    IOs.write(ds, mLength);
    IOs.write(ds, mPeptideKey);
    IOs.write(ds, mMH);
    // can't write the actual object. to avoid recursive
    // write the peptide seq key and MH so we can hook up the right frag at later time
    IOs.write(ds, mPrev!=null?mPrev.mMH:0f);
  }

  @Override
  public void read(DataInput ds) throws IOException
  {
    mLength = IOs.read(ds, mLength);
    mPeptideKey = IOs.read(ds, mPeptideKey);
    mMH = IOs.read(ds, mMH);

    float p = IOs.read(ds, mMH);
    if (p!=0f) mPrev = new FragmentEntry(p, 0, null, 0);
  }
}
{'fraction_non_alphanumeric': 0.12550403225806453, 'fraction_numerical': 0.010080645161290322, 'mean_word_length': 3.4495515695067263, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 5, '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': '4613620', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1395, 'n_words': 338}