Skip to content

Commit

Permalink
fix: Restriction enzymes' sequence was not set
Browse files Browse the repository at this point in the history
Also fixed builds on Linux fixing typo in font management.
Series of debug messages.
  • Loading branch information
smoe committed Aug 29, 2024
1 parent c48bfb3 commit 17f1d45
Show file tree
Hide file tree
Showing 23 changed files with 1,056 additions and 420 deletions.
23 changes: 12 additions & 11 deletions src/MyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void MyFrame::initme ()
// myapp()->sw.Start() ;

#ifdef __WXGTK__
wxFont f ( wxFontInfo ( 8 ).Family( wxFONTFAMILY_SWISS ).Style( wxFONTSTYLE_NORMAL ).Weight( wxFONWEIGHT_NORMAL ) ) ;
wxFont f ( wxFontInfo ( 8 ).Family( wxFONTFAMILY_SWISS ).Style( wxFONTSTYLE_NORMAL ).Weight( wxFONTWEIGHT_NORMAL ) ) ;
SetFont ( f ) ;
#endif

Expand Down Expand Up @@ -2075,25 +2075,26 @@ void MyFrame::removeChild ( ChildBase *ch )
/** \brief Activates a child (brings to front, makes visible, etc.)
\param childno - position of child in children list, starts with 0
*/
void MyFrame::activateChild ( const int childno )
void MyFrame::activateChild ( const unsigned int childno )
{
//wxPrintf( "D: MyFrame::activateChild( %d ) - start\n" , childno) ;
size_t numberOfChildren = children.GetCount() ;
if ( ! numberOfChildren )
{
//wxPrintf( "D: MyFrame::activateChild( %d ) - beyond number of children ( = %d), choosing NULL\n" , childno, children.GetCount() ) ;
wxPrintf( "D: MyFrame::activateChild( %u ) - beyond number of children ( = %lu), choosing NULL\n" , childno, children.GetCount() ) ;
setActiveChild ( NULL ) ;
}
else
{
if ( childno >= children.GetCount() )
int childtoactivate = childno ;
if ( childtoactivate >= children.GetCount() )
{
//wxPrintf( "D: MyFrame::activateChild( %d ) - beyond number of children ( = %d), choosing first\n" , childno, children.GetCount() ) ;
childno = 0 ;
wxPrintf( "W: MyFrame::activateChild( %u ) - beyond number of children ( = %lu), choosing first\n" , childno, children.GetCount() ) ;
childtoactivate = 0 ; // not const
}
children[childno]->Activate () ;
mainTree->EnsureVisible ( children[childno]->inMainTree ) ;
mainTree->SelectItem ( children[childno]->inMainTree ) ;
children[childtoactivate]->Activate () ;
mainTree->EnsureVisible ( children[childtoactivate]->inMainTree ) ;
mainTree->SelectItem ( children[childtoactivate]->inMainTree ) ;
}
//wxSafeYield () ;
//wxPrintf( "D: MyFrame::activateChild( %d ) - end\n" ) ;
Expand Down Expand Up @@ -2167,7 +2168,7 @@ wxString MyFrame::check4update ()
return text ;
}

wxString MyFrame::check4update_sub ( const wxString& text ) const
wxString MyFrame::check4update_sub ( const wxString& text ) /* not const */
{
bool error = true ;
if ( !text.IsEmpty() ) error = false ;
Expand All @@ -2190,7 +2191,7 @@ wxString MyFrame::check4update_sub ( const wxString& text ) const
{
wxString msg = it.AfterFirst ( '\n' ) ;
msg += "\n(" + wxString ( txt("t_you_use_version") ) + myapp()->get_GENtle_version() + ")" ;
wxMessageDialog md ( this , msg , txt("t_new_version" ) , wxOK | wxCANCEL | wxCENTRE | wxICON_INFORMATION ) ;
wxMessageDialog md ( /* not const */ this , msg , txt("t_new_version" ) , wxOK | wxCANCEL | wxCENTRE | wxICON_INFORMATION ) ;
if ( wxID_OK != md.ShowModal() )
{
return "-" ;
Expand Down
2 changes: 1 addition & 1 deletion src/MyFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class MyFrame : public MyFrameType
virtual void setActiveChild ( ChildBase * const c ) ;
virtual wxWindow* getCommonParent() const ;
virtual int getChildIndex ( const ChildBase * const c ) const ;
virtual void activateChild ( const int childno ) ;
virtual void activateChild ( const unsigned int childno ) ;
virtual void lockDisplay ( const bool lock = true ) ;
virtual bool isLocked () const ;
virtual bool isActivating () const ;
Expand Down
2 changes: 1 addition & 1 deletion src/PCR_Troubleshoot.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** \file
\brief Contains the FindSequenceDialog class
\brief Contains the PCR_troubleshoot_dialog class
*/
#ifndef _PCRTROUBLESHOOT_H_
#define _PCRTROUBLESHOOT_H_
Expand Down
18 changes: 18 additions & 0 deletions src/PrimerDesign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ TPrimerDesign::TPrimerDesign(wxWindow *parent, const wxString& title, TVector *_
}

for ( int a = 0 ; a < primer.size() ; a++ )
{
primer[a].getSequenceFromVector ( vec ) ;
}

def = _T("PrimerDesign") ;
from = -1 ;
Expand Down Expand Up @@ -161,8 +163,12 @@ void TPrimerDesign::OnImportPrimer ( wxCommandEvent &ev )
wxArrayChildBase cbl ;

for ( int a = 0 ; a < myapp()->frame->children.GetCount() ; a++ )
{
if ( myapp()->frame->children[a] && myapp()->frame->children[a]->vec && myapp()->frame->children[a]->vec->getType() == TYPE_PRIMER )
{
cbl.Add ( myapp()->frame->children[a] ) ;
}
}

if ( cbl.GetCount() == 0 )
{
Expand All @@ -172,7 +178,9 @@ void TPrimerDesign::OnImportPrimer ( wxCommandEvent &ev )

wxString *sl = new wxString[cbl.GetCount()] ;
for ( int a = 0 ; a < cbl.GetCount() ; a++ )
{
sl[a] = cbl[a]->getName() ;
}

TMyMultipleChoiceDialog scd ( this , txt("t_chose_primer_txt") , txt("t_chose_primer") , cbl.GetCount() , sl) ;

Expand Down Expand Up @@ -324,7 +332,9 @@ void TPrimerDesign::updatePrimerStats ()
lc->SetItem ( l , 6 , wxString::Format ( _T("%d") , primer[a].from ) ) ;
}
for ( int a = 0 ; a <= 6 ; a++ )
{
lc->SetColumnWidth ( a , wxLIST_AUTOSIZE_USEHEADER ) ;
}
stat->SetValue ( _T("") ) ;
lastPrimerActivated = -1 ;
}
Expand Down Expand Up @@ -473,7 +483,9 @@ void TPrimerDesign::initme ()
spinTextEnabeled = true ;
sc->SetFocus() ;
for ( int a = 0 ; a < lc->GetColumnCount() ; a++ )
{
lc->SetColumnWidth ( a , wxLIST_AUTOSIZE_USEHEADER ) ;
}
}

void TPrimerDesign::OnEditPrimer ( wxCommandEvent &ev )
Expand All @@ -492,7 +504,9 @@ void TPrimerDesign::OnDeletePrimer ( wxCommandEvent &ev )
if ( lastPrimerActivated == -1 ) return ;
if ( primer.size() == 0 ) return ;
for ( int a = lastPrimerActivated ; a + 1 < primer.size() ; a++ )
{
primer[a] = primer[a+1] ;
}
primer.pop_back () ;
lastPrimerActivated = -1 ;
showSequence () ;
Expand Down Expand Up @@ -540,8 +554,12 @@ void TPrimerDesign::showSequence ()
p1->myname = _T("PRIMER_UP") ;
p1->alternateName = txt("t_primer_up") ;
for ( int a = 0 ; a < primer.size() ; a++ )
{
if ( primer[a].upper )
{
p1->addPrimer ( &primer[a] ) ;
}
}

// Upper template sequence
SeqDNA *s1 = new SeqDNA ( sc ) ;
Expand Down
61 changes: 53 additions & 8 deletions src/ProgramOptionsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ END_EVENT_TABLE()

TEnzymeSettingsTab::TEnzymeSettingsTab ( wxWindow *parent , const int _mode ) : wxPanel ( parent )
{
wxPrintf( "D: TEnzymeSettingsTab::TEnzymeSettingsTab - start\n" ) ;
myapp()->frame->push_help ( _T("GENtle:Options") ) ;
mode = _mode ;
int w , h ;
Expand Down Expand Up @@ -129,6 +130,8 @@ TEnzymeSettingsTab::TEnzymeSettingsTab ( wxWindow *parent , const int _mode ) :
this->Show () ;
updateGlobalEnzymes () ;
vs->Fit ( this ) ;

wxPrintf( "D: TEnzymeSettingsTab::TEnzymeSettingsTab - end\n" ) ;
}

ProgramOptionsDialog::~ProgramOptionsDialog ()
Expand All @@ -138,6 +141,7 @@ ProgramOptionsDialog::~ProgramOptionsDialog ()

void TEnzymeSettingsTab::updateGlobalEnzymes ()
{
wxPrintf( "D: TEnzymeSettingsTab::updateGlobalEnzymes - start\n" ) ;
bool use = useSettings->GetValue() ;
useMinCutoff->Enable ( use ) ;
useMaxCutoff->Enable ( use ) ;
Expand All @@ -159,6 +163,7 @@ void TEnzymeSettingsTab::updateGlobalEnzymes ()
updateColorButton ( bcol1 , col1 ) ;
updateColorButton ( bcol2 , col2 ) ;
updateColorButton ( bcol3 , col3 ) ;
wxPrintf( "D: TEnzymeSettingsTab::updateGlobalEnzymes - end - useMaxCutoff:%d\n" , useMaxCutoff ) ;
}

void TEnzymeSettingsTab::updateColorButton ( wxButton *b , const wxColour &c )
Expand Down Expand Up @@ -202,14 +207,19 @@ void TEnzymeSettingsTab::OnButton3 ( wxCommandEvent &event )

void TEnzymeSettingsTab::updateColor ( wxColour &c )
{
wxPrintf("D: TEnzymeSettingsTab::updateColor(%s)\n",c.GetAsString()) ;
wxPrintf("D: TEnzymeSettingsTab::updateColor(%s) - start\n",c.GetAsString()) ;

wxColour c2 = wxGetColourFromUser ( this , c ) ;
wxPrintf("D: TEnzymeSettingsTab wxGetColourFromUser -> %s\n",c2.GetAsString()) ;
wxPrintf("D: TEnzymeSettingsTab::updateColor(%s) wxGetColourFromUser -> %s\n" , c.GetAsString() , c2.GetAsString()) ;

if ( !c2.Ok() ) return ;
if ( !c2.Ok() )
{
wxPrintf("D: TEnzymeSettingsTab::updateColor(%s) -> ret !c2.Ok()" ,c.GetAsString() , c2.GetAsString()) ;
return ;
}
c = c2 ;
updateGlobalEnzymes () ;
wxPrintf("D: TEnzymeSettingsTab::updateColor(%s) - end\n",c.GetAsString()) ;
}


Expand Down Expand Up @@ -449,9 +459,11 @@ void TEnzymeRules::init () // Default settings

void TEnzymeRules::load_global_settings () /* not const */
{
wxPrintf( "D: TEnzymeRules::load_global_settings - start\n" ) ;
init () ;
wxString s = myapp()->frame->LS->getOption ( _T("GLOBALENZYMESETTINGS") , _T("") ) ;
from_string ( s ) ;
wxPrintf( "D: TEnzymeRules::load_global_settings - end\n" ) ;
}

void TEnzymeRules::save_global_settings () const
Expand Down Expand Up @@ -543,8 +555,9 @@ wxString TEnzymeRules::to_string () const
return ret ;
}

void TEnzymeRules::from_string ( const wxString &s )
void TEnzymeRules::from_string ( const wxString& s )
{
wxPrintf( "D: TEnzymeRules::from_string - start\n" ) ;
init () ;
wxArrayString as ;
explode ( _T("\r") , s , as ) ;
Expand Down Expand Up @@ -576,6 +589,7 @@ void TEnzymeRules::from_string ( const wxString &s )
else if ( key == _T("methylation") ) methylation = l ;
else if ( key == _T("showgc") ) showgc = l ;
}
wxPrintf( "D: TEnzymeRules::from_string - end\n" ) ;
}

wxColour TEnzymeRules::scan_color ( const wxString& s ) const
Expand All @@ -600,9 +614,26 @@ wxColour *TEnzymeRules::getColor ( const int cuts )

void TEnzymeRules::getVectorCuts ( /* not const */ TVector * const v ) const
{
wxPrintf( "D: TEnzymeRules::getVectorCuts - start ( on %s )\n" , v->getName() ) ;
for ( int a = 0 ; a < v->re.GetCount() ; a++ )
{
if ( NULL == v->re[a] )
{
wxPrintf( "E: Found first restriction enzyme re[%d] that is NULL.\n" , a ) ;
abort() ;
}
if ( v->re[a]->getSequence().IsEmpty() )
{
wxPrintf( "E: Found first restriction enzyme (%s) with empty sequence.\n" , v->re[a]->getName() ) ;
abort() ;
}
v->getCuts ( v->re[a] , /* not const */ v->rc , false ) ;
if ( !useit ) return ;
}
if ( !useit )
{
wxPrintf( "D: TEnzymeRules::getVectorCuts - ret !useit ( on %s )\n" , v->getName() ) ;
return ;
}

// Getting the default list of enzymes
wxArrayTRestrictionEnzyme ve ;
Expand Down Expand Up @@ -640,17 +671,31 @@ void TEnzymeRules::getVectorCuts ( /* not const */ TVector * const v ) const

// Add what has the correct number of cuts
v->re2.Clear () ; // The list of used enzymes that were *not* added manually
int max = 10000000 ; // Ridiculously high number
int max = 500 ; // Upper limit of what GENtle can display as it seems
if ( use_max_cutoff ) max = max_cutoff ;
for ( int a = 0 ; a < ve.GetCount() ; a++ )
{
vector <TRestrictionCut> vc ;
v->getCuts ( ve[a] , vc , false , max ) ;
if ( ( !use_min_cutoff || min_cutoff <= vc.size() ) && ( !use_max_cutoff || max_cutoff >= vc.size() ) )
if ( use_min_cutoff && min_cutoff <= vc.size() )
{
wxPrintf( "D: TEnzymeRules::getVectorCuts - min cutoff - enzyme:%s vc.size():%lu\n" , ve[a]->getName() , vc.size() ) ;
}
else if ( use_max_cutoff && max_cutoff >= vc.size() )
{
wxPrintf( "D: TEnzymeRules::getVectorCuts - max cutoff - enzyme:%s vc.size():%lu\n" , ve[a]->getName() , vc.size() ) ;
}
else
{
wxPrintf( "D: TEnzymeRules::getVectorCuts - accepting - enzyme:%s vc.size():%lu\n" , ve[a]->getName() , vc.size() ) ;
v->re2.Add ( ve[a] ) ;
for ( int b = 0 ; b < vc.size() ; b++ ) v->rc.push_back ( vc[b] ) ;
for ( int b = 0 ; b < vc.size() ; b++ )
{
v->rc.push_back ( vc[b] ) ;
}
}
}

wxPrintf( "D: TEnzymeRules::getVectorCuts - end - (for %s, v->re2.GetCount(): %lu)\n" , v->getName(), v->re2.GetCount() ) ;
}

6 changes: 4 additions & 2 deletions src/ProgramOptionsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ class TEnzymeRules
virtual wxColour *getColor ( const int cuts ) ; ///< Returns a pointer to a wxColour structure with the correct color for the given number of cuts

bool useit ;
int min_cutoff , max_cutoff ;
bool use_min_cutoff , use_max_cutoff ;
int min_cutoff ;
int max_cutoff ; ///< limits the maximal number of cuts for an enzyme on a single sequence to be accepted
bool use_min_cutoff ;
bool use_max_cutoff ; ///< flag to enforce maximal number of cuts for an enzyme on a single sequence
bool recog4 , recog5 , recog6 , recog_longer ;
bool pattern3 , pattern5 , pattern_blunt ;
bool showgc ;
Expand Down
Loading

0 comments on commit 17f1d45

Please sign in to comment.