<commit_before>
package CXGN::Cross;

use Moose;
use SGN::Model::Cvterm;
use Data::Dumper;

has 'bcs_schema' => ( isa => 'Bio::Chado::Schema',
	is => 'rw',
	required => 1,
);

has 'cross_stock_id' => (isa => "Int",
	is => 'rw',
	required => 0,
);

has 'female_parent' => (isa => 'Str',
  is => 'rw',
	required => 0,
);

has 'male_parent' => (isa => 'Str',
  is => 'rw',
	required => 0,
);



sub get_cross_relationships {
	my $self = shift;
	my $crs = $self->bcs_schema->resultset("Stock::StockRelationship")->search( { object_id => $self->cross_stock_id } );

	my $maternal_parent = "";
	my $paternal_parent = "";
	my @progeny = ();

	foreach my $child ($crs->all()) {
		if ($child->type->name() eq "female_parent") {
			$maternal_parent = [ $child->subject->name, $child->subject->stock_id() ];
		}
		if ($child->type->name() eq "male_parent") {
			$paternal_parent = [ $child->subject->name, $child->subject->stock_id() ];
		}
		if ($child->type->name() eq "member_of") {
			push @progeny, [ $child->subject->name, $child->subject->stock_id() ];
		}
	}
	return ($maternal_parent, $paternal_parent, \@progeny);
}


sub get_cross_info {
    my $self = shift;
		my $female_parent = $self->female_parent;
		my $male_parent = $self->male_parent;
		my $schema = $self->bcs_schema();
    my $male_parent_typeid = SGN::Model::Cvterm->get_cvterm_row($schema, "male_parent", "stock_relationship")->cvterm_id();
    my $female_parent_typeid = SGN::Model::Cvterm->get_cvterm_row($schema, "female_parent", "stock_relationship")->cvterm_id();
    my $cross_typeid = SGN::Model::Cvterm->get_cvterm_row($schema, "cross", "stock_type")->cvterm_id();

		my $where_female = "";
	  if ($female_parent){
		$where_female = " WHERE female_parent.uniquename = '$female_parent'";
	  };

		my $where_male ="";
		if ($male_parent){
			$where_male = " AND male_parent.uniquename = '$male_parent'";
		}

   my $q = "SELECT female_parent.stock_id, male_parent.stock_id, cross_entry.stock_id, female_parent.uniquename, male_parent.uniquename, cross_entry.uniquename, stock_relationship1.value
    FROM stock as female_parent INNER JOIN stock_relationship AS stock_relationship1 ON (female_parent.stock_id=stock_relationship1.subject_id)
    AND stock_relationship1.type_id= ? INNER JOIN stock AS cross_entry ON (cross_entry.stock_id=stock_relationship1.object_id) AND cross_entry.type_id= ?
		LEFT JOIN stock_relationship AS stock_relationship2 ON (cross_entry.stock_id=stock_relationship2.object_id) AND stock_relationship2.type_id= ?
		LEFT JOIN stock AS male_parent ON (male_parent.stock_id=stock_relationship2.subject_id)
    $where_female $where_male ORDER BY stock_relationship1.value";

		my $h = $schema->storage->dbh()->prepare($q);


				$h->execute($female_parent_typeid, $cross_typeid, $male_parent_typeid);



		my @cross_info = ();
    while (my ($female_parent_id, $male_parent_id, $cross_entry_id, $female_parent_name, $male_parent_name, $cross_name, $cross_type) = $h->fetchrow_array()){
			push @cross_info, [$female_parent_id, $female_parent_name, $male_parent_id, $male_parent_name, $cross_entry_id, $cross_name, $cross_type]
		}

		return \@cross_info;<commit_msg>trying to change indent in Atom...<commit_after>
package CXGN::Cross;

use Moose;
use SGN::Model::Cvterm;
use Data::Dumper;

has 'bcs_schema' => ( isa => 'Bio::Chado::Schema',
  is => 'rw',
  required => 1,
);

has 'cross_stock_id' => (isa => "Int",
  is => 'rw',
  required => 0,
);

has 'female_parent' => (isa => 'Str',
  is => 'rw',
  required => 0,
);

has 'male_parent' => (isa => 'Str',
  is => 'rw',
  required => 0,
);



sub get_cross_relationships {
  my $self = shift;
  my $crs = $self->bcs_schema->resultset("Stock::StockRelationship")->search( { object_id => $self->cross_stock_id } );

  my $maternal_parent = "";
  my $paternal_parent = "";
  my @progeny = ();

  foreach my $child ($crs->all()) {
    if ($child->type->name() eq "female_parent") {
      $maternal_parent = [ $child->subject->name, $child->subject->stock_id() ];
    }
    if ($child->type->name() eq "male_parent") {
      $paternal_parent = [ $child->subject->name, $child->subject->stock_id() ];
    }
    if ($child->type->name() eq "member_of") {
      push @progeny, [ $child->subject->name, $child->subject->stock_id() ];
    }
  }
  return ($maternal_parent, $paternal_parent, \@progeny);
}


sub get_cross_info {
    my $self = shift;
    my $female_parent = $self->female_parent;
    my $male_parent = $self->male_parent;
    my $schema = $self->bcs_schema();
    my $male_parent_typeid = SGN::Model::Cvterm->get_cvterm_row($schema, "male_parent", "stock_relationship")->cvterm_id();
    my $female_parent_typeid = SGN::Model::Cvterm->get_cvterm_row($schema, "female_parent", "stock_relationship")->cvterm_id();
    my $cross_typeid = SGN::Model::Cvterm->get_cvterm_row($schema, "cross", "stock_type")->cvterm_id();

    my $where_female = "";
    if ($female_parent){
    $where_female = " WHERE female_parent.uniquename = '$female_parent'";
    };

    my $where_male ="";
    if ($male_parent){
      $where_male = " AND male_parent.uniquename = '$male_parent'";
    }

   my $q = "SELECT female_parent.stock_id, male_parent.stock_id, cross_entry.stock_id, female_parent.uniquename, male_parent.uniquename, cross_entry.uniquename, stock_relationship1.value
    FROM stock as female_parent INNER JOIN stock_relationship AS stock_relationship1 ON (female_parent.stock_id=stock_relationship1.subject_id)
    AND stock_relationship1.type_id= ? INNER JOIN stock AS cross_entry ON (cross_entry.stock_id=stock_relationship1.object_id) AND cross_entry.type_id= ?
    LEFT JOIN stock_relationship AS stock_relationship2 ON (cross_entry.stock_id=stock_relationship2.object_id) AND stock_relationship2.type_id= ?
    LEFT JOIN stock AS male_parent ON (male_parent.stock_id=stock_relationship2.subject_id)
    $where_female $where_male ORDER BY stock_relationship1.value";

    my $h = $schema->storage->dbh()->prepare($q);


        $h->execute($female_parent_typeid, $cross_typeid, $male_parent_typeid);



    my @cross_info = ();
    while (my ($female_parent_id, $male_parent_id, $cross_entry_id, $female_parent_name, $male_parent_name, $cross_name, $cross_type) = $h->fetchrow_array()){
      push @cross_info, [$female_parent_id, $female_parent_name, $male_parent_id, $male_parent_name, $cross_entry_id, $cross_name, $cross_type]
    }

    return \@cross_info;
{'fraction_non_alphanumeric': 0.16053042121684868, 'fraction_numerical': 0.00436817472698908, 'mean_word_length': 5.002808988764045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 111, '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': '3779888', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2273, 'n_words': 432}