<commit_before>#stupid RT bug # 74078 Need to create new reference to see builtin functions
our &shiftt = &shift;
our &op = &open;
our &s = &say;
role Bio::Role::FastaIO[$file]{

has @!results;
has $!fh;
use Bio::Grammar::Fasta;
use Bio::Grammar::Actions::Fasta;
 
method next_seq() {
  #rakudo bug, cannot use builtin functions in roles RT #74078
  return &shiftt(@!results);
}

#method will not be private and/or put in new buildmethod
method initial_read() {    
 	@!results = @(Bio::Grammar::Fasta.parsefile($file, :actions(Bio::Grammar::Actions::Fasta)).ast);	
}

method initial_write() {    
 	#rakudo bug RT #74078
 	#need error checking to ensure that we did indeed open a new file
 	$!fh = &op($file,:w);
}

method write_seq(*@seq){
 
 for @seq -> $seq {
   #need to ensure we have Bio::PrimarySeqI
   
   #most raw way to print out fasta files with no options whatsoever
   #no width of the sequence even!
   my $header = ">$seq.display_id() $seq.description()";
   my $sequence = $seq.seq();

   $!fh.say($header ~ "\n" ~ $seq.seq());   
   
 }
 
}

}<commit_msg>Now have default width of 80 when parsing out the sequence data. thanks mortiz_++<commit_after>#stupid RT bug # 74078 Need to create new reference to see builtin functions
our &shiftt = &shift;
our &op = &open;
our &s = &say;
use Bio::Grammar::Fasta;
use Bio::Grammar::Actions::Fasta;
role Bio::Role::FastaIO[$file]{

has @!results;
has Int $!width=80;
has $!fh;

method next_seq() {
  #rakudo bug, cannot use builtin functions in roles RT #74078
  return &shiftt(@!results);
}

#method will not be private and/or put in new buildmethod
method initial_read() {    
 	@!results = @(Bio::Grammar::Fasta.parsefile($file, :actions(Bio::Grammar::Actions::Fasta)).ast);	
}

method initial_write() {    
 	#rakudo bug RT #74078
 	#need error checking to ensure that we did indeed open a new file
 	$!fh = &op($file,:w);
}

method write_seq(*@seq){
 
 for @seq -> $seq {
   #need to ensure we have Bio::PrimarySeqI
   
   #most raw way to print out fasta files with no options whatsoever
   my $header = ">$seq.display_id() $seq.description()";

   #no variable interploation yet! 
   #my $sequence = $seq.seq().comb( /. ** {1..$width}/).join("\n");

   my $sequence = $seq.seq().comb( /. ** 1..80/).join("\n");
   $!fh.say($header ~ "\n" ~ $sequence);   
   
 }
 
}

}

{'fraction_non_alphanumeric': 0.1579623287671233, 'fraction_numerical': 0.016267123287671232, 'mean_word_length': 3.89937106918239, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5594862', 'n_tokens_mistral': 885, 'n_tokens_neox': 821, 'n_words': 263}