<commit_before>from StringIO import StringIO
from unittest import TestCase, expectedFailure

import networkx as nx
import numpy as np
from mock.mock import patch
from networkx.algorithms.isomorphism.isomorph import is_isomorphic

from Automated_Design.adj_scaf_nick_pos import adj_scaf_nick_pos
from Automated_Design.adj_scaf_nick_pos import get_scaf_nick_pos
from Automated_Design.assign_scaf_to_edge import assign_scaf_to_edge
from Automated_Design.assign_staples_wChoices import assign_staples_wChoices
from Automated_Design.designate_edge_type import designate_edge_type
from Automated_Design.enum_scaf_bases_DX import enum_scaf_bases_DX
from Automated_Design.gen_stap_seq import gen_stap_seq
from Automated_Design.ply_to_input import ply_to_input
from Automated_Design.set_routing_direction import set_routing_direction
from Automated_Design.split_edge import split_edge
from Automated_Design.split_vert import split_vert
from Automated_Design.dna_info import DnaInfo, calc_buff, d, wDX, gen_FE_norms
from tests.sample_data import ply_file_01_tetrahedron, ply_file_05_icosahedron
from tests.target_parsers import load_mat_file, load_graph_from_mat, \
    load_pseudonodes_from_mat, load_1d_list_from_mat, load_single_value, \
    load_edges_from_mat, load_faces_from_mat, load_vert_to_face_from_mat, \
    load_scaf_to_edge_from_mat, load_staples_from_mat, load_stap_seq_file, \
    load_stap_seq_list_file, load_stap_list_file, \
    load_named_stap_seq_list_file, load_dna_info
from tests.utils import open_string_as_file


@patch('Automated_Design.plotters.plot_edge_length_distributions')
def test_ply_input_for_01_tetrahedron(self, savefig_mock):
    f = open_string_as_file(ply_file_01_tetrahedron)
    coordinates, edges, faces, edge_length_vec, file_name, \
        staple_name, singleXOs = ply_to_input(
            "01_tetrahedron", f, min_len_nt=52)
    self.assertEqual(len(coordinates), 4)
    self.assertEqual(len(faces), 4)


@patch('Automated_Design.plotters.plot_edge_length_distributions')
def test_ply_input_for_05_icosahedron(self, savefig_mock):
    f = open_string_as_file(ply_file_05_icosahedron)
    coordinates, edges, faces, edge_length_vec, file_name, \
        staple_name, singleXOs = ply_to_input(
            "05_tetrahedron", f, min_len_nt=52)
    self.assertEqual(len(coordinates), 12)
    self.assertEqual(len(faces), 20)

<commit_msg>Fixed 'self' error in tests.<commit_after>from StringIO import StringIO
from unittest import TestCase, expectedFailure

import networkx as nx
import numpy as np
from mock.mock import patch
from networkx.algorithms.isomorphism.isomorph import is_isomorphic

from Automated_Design.adj_scaf_nick_pos import adj_scaf_nick_pos
from Automated_Design.adj_scaf_nick_pos import get_scaf_nick_pos
from Automated_Design.assign_scaf_to_edge import assign_scaf_to_edge
from Automated_Design.assign_staples_wChoices import assign_staples_wChoices
from Automated_Design.designate_edge_type import designate_edge_type
from Automated_Design.enum_scaf_bases_DX import enum_scaf_bases_DX
from Automated_Design.gen_stap_seq import gen_stap_seq
from Automated_Design.ply_to_input import ply_to_input
from Automated_Design.set_routing_direction import set_routing_direction
from Automated_Design.split_edge import split_edge
from Automated_Design.split_vert import split_vert
from Automated_Design.dna_info import DnaInfo, calc_buff, d, wDX, gen_FE_norms
from tests.sample_data import ply_file_01_tetrahedron, ply_file_05_icosahedron
from tests.target_parsers import load_mat_file, load_graph_from_mat, \
    load_pseudonodes_from_mat, load_1d_list_from_mat, load_single_value, \
    load_edges_from_mat, load_faces_from_mat, load_vert_to_face_from_mat, \
    load_scaf_to_edge_from_mat, load_staples_from_mat, load_stap_seq_file, \
    load_stap_seq_list_file, load_stap_list_file, \
    load_named_stap_seq_list_file, load_dna_info
from tests.utils import open_string_as_file


@patch('Automated_Design.plotters.plot_edge_length_distributions')
def test_ply_input_for_01_tetrahedron(savefig_mock):
    f = open_string_as_file(ply_file_01_tetrahedron)
    coordinates, edges, faces, edge_length_vec, file_name, \
        staple_name, singleXOs = ply_to_input(
            "01_tetrahedron", f, min_len_nt=52)
    assert len(coordinates) == 4
    assert len(faces) == 4


@patch('Automated_Design.plotters.plot_edge_length_distributions')
def test_ply_input_for_05_icosahedron(savefig_mock):
    f = open_string_as_file(ply_file_05_icosahedron)
    coordinates, edges, faces, edge_length_vec, file_name, \
        staple_name, singleXOs = ply_to_input(
            "05_tetrahedron", f, min_len_nt=52)
    assert len(coordinates) == 12
    assert len(faces) == 19


{'fraction_non_alphanumeric': 0.05323435843054083, 'fraction_numerical': 0.011452810180275715, 'mean_word_length': 7.020408163265306, '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': '943031', 'n_tokens_mistral': 1723, 'n_tokens_neox': 1623, 'n_words': 298}