
# evgsubmitkfish2fc15.info
# also /bio-grid/kfish2/submitf/evgsubmitkfish2.info

#...........................................
# submit set scripts
# ----------------

  env  debug=1 ./makebesttab345.pl  > gmapn/findcds4upd/kfish2all5_fcds45.besttab7
  
      # v5 .. now besttab5d, fc14f >> 5e, fc14g
      # v6: findcds upd fcds6 >> ** also gmapnsub3
      ## fcds6 BUGGERS some findcds have inner STOPs in prot; should not be, or be flagged **
      ## fcds6 besttab6 also has some splits over cdsspan as cds2aa best, should not be: best=pubaa
      ## fcds6 also screws up CDS Split= assignments due to ? found bug, exon Split not copied to CDS;

  # update ERRrev fix to besttab.. problems?
  btab=besttab7l
    ## n=29; nswap1=23; rest are t1=err:splitC1+/- << ignore these, problem is t1-split, likely real genoasm mixup
    ## update to besttab.fixrev1
  perl -ne '($pd,$bd,$mps,$aas,$hod,$hov,$aad,$aaw,$cdo,$cov,$pi,$loc,$np,$osrc)=split"\t"; 
  ($gd,$ti)= $pd=~m/(\w+t)(\d+)$/; $gloc{$gd}{$ti}=$loc; ($to)=$loc=~m/:([+\.\-])/; $to=0 if($to eq "."); 
  $to1=$to if($ti == 1); if($lg eq $gd) { if($to and $to1 and $to ne $to1 and not($loc=~m/,err:/)) { 
  $gloc=$gloc{$gd}{1}; ($gr)=split":",$gloc; ($tr)=split":",$loc;
  if($gr eq $tr and /swap1:/) { $el="$loc,err:ERRrev1"; s/\t$loc\t/\t$el\t/; } } } print; $lg=$gd;'\
    kfish2all5_fcds45.$btab > kfish2all5_fcds45.$btab.fixerr1

  
  # fc14e,f : add new pre-calc of locustag.tbl in evgkfish2subgff.pl, read all in.gff (main,alt),
  # find output set, then calc locustag from splits of all locus main,alt tr 
  # .. or do this after evgkfish2subgff.pl, updating just locustag= fields
  # ** bestgenes_update.pl -cadd addlocus=1 is now doing this. OK?
  # fc14h: endgap trim test..
  # fc14i: besttab5h corrections ..
  # fc14m5 or fc14o1  changes: gapfix.gff added, several other fixes ..
  # fc14o2 .. findcds bug split C1 mRNA span forced to cover both parts, fixme 
  # .. findcds bug CDS split part wrong (for some), sorted to end, all are Split=2 C1: only?
  
  #* NEED gapfix updates per last version?? or AFTER evgkfish2subgff  
  # OR: as now, add next step  env gapfix=1 debug=1 ./evgkfish2subgff.pl  in.gff TO $ppt.gff
  #....................
  
  # pull subset.gff of knset8.fa scafs to test.
  vers=fc15d3
  pt=kfish2rae5h_asm3n_$vers
  ppt=kfish2rae5h_fc15_all
  
  env vers=$vers debug=1 ./evgkfish2subgff.pl >& gmapnsub3/log.evgsub$vers
  env vers=${vers}alt putalt=1 debug=1 ./evgkfish2subgff.pl >& gmapnsub3/log.evgsub${vers}alt

  env gapfix=1 vers=$vers debug=1 ./evgkfish2subgff.pl gmapnsub3/kfish2rae5h_asm3n_$vers*.gff
  cat gmapnsub3/kfish2rae5h_fx_$vers.{gapnot,gapfix}.gff  > gmapnsub3/$ppt.gff
      
  # sort by scaf/genes, add gene rows
  # ** -cadd addlocus=1 for dang ncbi locus_tag for splitgenes geneidA,geneidB,..
  # * scaf-sort bug now for splits, split main A,B KN807334.1,KN811454.1 followd by alts A KN807334.1 out of order
  
  $evigene/scripts/bestgenes_update.pl -act=sort -cadd addlocus=1 -cadd addgene=1 -debug \
     -vers kf2rae5h5 -conf  pubgenome/evigene_kfish2_gbsubmit.conf \
      -in gmapnsub3/$ppt.gff -out gmapnsub3/$ppt.gff3

  # pull out aa, only bestaa=pubaa for _all, works better now for splits; revise? 
  grep mRNA gmapnsub3/$ppt.gff3 | grep protein= | grep bestaa=pubaa | perl -ne\
'($d)=m/ID=([^;\s]+)/; ($p)=m/protein=([^;\s]+)/; ($aw)=m/(aalen=[^;\s]+)/; print ">$d $aw;\n$p\n" unless($did{$d}++);'\
    > gmapnsub3/$ppt.aa

  # make submit table
  ./evigene2genotbl_kfish2.pl -notbl2asn -skipnoann -debug \
  -conf pubgenome/evigene_kfish2_gbsubmit.conf \
  -proteins gmapnsub3/$ppt.aa -in gmapnsub3/$ppt.gff3 -out gmapnsub3/$ppt.tbl \
    >& gmapnsub3/$ppt.tbl.log

  cd  gmapnsub3/
  rename "\.all" ""  $ppt.all.{tbl,pep}
  # ln -s ../pubgenome/ncbifunhe302scaf.fa $ppt.fa
  
  # run tbl2asn ..
  $nbin/tbl2asn -Mn -Vbv -a r10k -XE -Hy \
  -t ./kfish2rae5gsub.sbt -w ./kfish2rae5gsubmethods.cmt -Y ./kfish2rae5gsubdesc.cmt \
  -j '[moltype=DNA] [organism=Fundulus_heteroclitus]'   \
  -Z $ppt.discr -i $ppt.fa -f $ppt.tbl > $ppt.tasn.log 2>&1

  mv errorsummary.val $ppt.valsum

#----------------------

