<commit_before>package org.biojava.nbio.structure.basepairs;

import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureIO;
import org.biojava.nbio.structure.basepairs.BasePairParameters;
import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.*;

/**
 * Contributed to BioJava under it's LGPL
 * Created by <NAME> on 7/21/17.
 */
public class TestBasePairParameters {

    @Test
    public void testBasePair() throws IOException, StructureException {

        Structure structure = StructureIO.getStructure("1KX5");

        BasePairParameters bp = new BasePairParameters(structure);
        bp.analyze();
        String sequence = bp.getPairSequence();

        assertEquals(bp.getPairingParameters().length, 147);
        // below all this set of comparator data was from an external program, 3DNA.
        // next three in degrees: buckle, propeller, opening
        assertEquals(bp.getBuckle(0), -3.796, 0.1);
        assertEquals(bp.getPropeller(0), 4.482, 0.1);
        assertEquals(bp.getOpening(0), -0.730, 0.1);
        // next three in Å: shear, stretch, stagger
        assertEquals(bp.getShear(0), -0.324, 0.02);
        assertEquals(bp.getStretch(0), -0.578, 0.02);
        assertEquals(bp.getStagger(0), -0.336, 0.02);
        // next three in degrees: tilt, roll, twist
        assertEquals(bp.getTilt(0), 2.354, 0.1);
        assertEquals(bp.getRoll(0), 0.785, 0.1);
        assertEquals(bp.getTwist(0), 32.522, 0.5);
        // next three in Å, shift, slide, rise
        assertEquals(bp.getShift(0), -0.873, 0.02);
        assertEquals(bp.getSlide(0), -0.607, 0.02);
        assertEquals(bp.getRise(0), 3.070, 0.02);


        structure = StructureIO.getStructure("3PHP");
        bp = new TertiaryBasePairParameters(structure, true, false).analyze();
        assertEquals(9, bp.getPairingParameters().length);

        double[][] pairs = bp.getPairingParameters();
        double[][] steps = bp.getStepParameters();

        // test against values given by 3DNA, just using the raw arrays
        assertEquals(pairs[4][0], 0.060, 0.1);
        assertEquals(pairs[4][1], -9.323, 0.1);
        assertEquals(pairs[4][2], -5.109, 0.1);
        // next three in Å: shear, stretch, stagger
        assertEquals(pairs[4][3], 0.126, 0.02);
        assertEquals(pairs[4][4], -0.177, 0.02);
        assertEquals(pairs[4][5], 0.273, 0.02);
        // next three in degrees: tilt, roll, twist
        assertEquals(steps[4][0], -1.456, 0.1);
        assertEquals(steps[4][1], 6.583, 0.1);
        assertEquals(steps[4][2], 33.234, 0.5);
        // next three in Å, shift, slide, rise
        assertEquals(steps[4][3], -0.735, 0.02);
        assertEquals(steps[4][4], -0.978, 0.02);
        assertEquals(steps[4][5], 3.491, 0.02);



        structure = StructureIO.getStructure("1P71");

        bp = new MismatchedBasePairParameters(structure, false, false, false).analyze();<commit_msg>Added new getters and refined tests<commit_after>package org.biojava.nbio.structure.basepairs;

import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureIO;
import org.biojava.nbio.structure.basepairs.BasePairParameters;
import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.*;

/**
 * Contributed to BioJava under it's LGPL
 * Created by <NAME> on 7/21/17.
 */
public class TestBasePairParameters {

    @Test
    public void testBasePair() throws IOException, StructureException {

        Structure structure = StructureIO.getStructure("1KX5");

        BasePairParameters bp = new BasePairParameters(structure);
        bp.analyze();
        String sequence = bp.getPairSequence();

        assertEquals(bp.getPairingParameters().length, 147);
        // below all this set of comparator data was from an external program, 3DNA.
        // next three in degrees: buckle, propeller, opening
        assertEquals(bp.getBuckle(0), -3.796, 0.1);
        assertEquals(bp.getPropeller(0), 4.482, 0.1);
        assertEquals(bp.getOpening(0), -0.730, 0.1);
        // next three in Å: shear, stretch, stagger
        assertEquals(bp.getShear(0), -0.324, 0.02);
        assertEquals(bp.getStretch(0), -0.578, 0.02);
        assertEquals(bp.getStagger(0), -0.336, 0.02);
        // next three in degrees: tilt, roll, twist
        assertEquals(bp.getTilt(1), 2.354, 0.1);
        assertEquals(bp.getRoll(1), 0.785, 0.1);
        assertEquals(bp.getTwist(1), 32.522, 0.5);
        // next three in Å, shift, slide, rise
        assertEquals(bp.getShift(1), -0.873, 0.02);
        assertEquals(bp.getSlide(1), -0.607, 0.02);
        assertEquals(bp.getRise(1), 3.070, 0.02);


        structure = StructureIO.getStructure("3PHP");
        bp = new TertiaryBasePairParameters(structure, true, false).analyze();
        assertEquals(9, bp.getPairingParameters().length);

        double[][] pairs = bp.getPairingParameters();
        double[][] steps = bp.getStepParameters();

        // test against values given by 3DNA, just using the raw arrays
        assertEquals(pairs[4][0], 0.060, 0.1);
        assertEquals(pairs[4][1], -9.323, 0.1);
        assertEquals(pairs[4][2], -5.109, 0.1);
        // next three in Å: shear, stretch, stagger
        assertEquals(pairs[4][3], 0.126, 0.02);
        assertEquals(pairs[4][4], -0.177, 0.02);
        assertEquals(pairs[4][5], 0.273, 0.02);
        // next three in degrees: tilt, roll, twist
        assertEquals(steps[4][0], -1.456, 0.1);
        assertEquals(steps[4][1], 6.583, 0.1);
        assertEquals(steps[4][2], 33.234, 0.5);
        // next three in Å, shift, slide, rise
        assertEquals(steps[4][3], -0.735, 0.02);
        assertEquals(steps[4][4], -0.978, 0.02);
        assertEquals(steps[4][5], 3.491, 0.02);



        structure = StructureIO.getStructure("1P71");

        bp = new MismatchedBasePairParameters(structure, false, false, false).analyze();
{'fraction_non_alphanumeric': 0.15009940357852883, 'fraction_numerical': 0.06991385023194169, 'mean_word_length': 2.92012987012987, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3233725', 'n_tokens_mistral': 2186, 'n_tokens_neox': 1906, 'n_words': 442}