Skip to content

Commit

Permalink
Fix display of restriction identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
smoe committed Dec 30, 2023
1 parent 93d3f93 commit 9e8dab4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 38 deletions.
3 changes: 1 addition & 2 deletions RestrictionEnzymes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void TRestrictionEnzyme::setSequence ( const wxString& sequence )
\param w Screen width
\param h Screen height
*/
void TRestrictionCut::linearUpdate ( const int w , const int h )
void TRestrictionCut::linearUpdate ( const int w , const int h ) /* not const */
{
p.x = lp.x * w / STANDARDRADIUS + 2 ;
p.y = lp.y * h / STANDARDRADIUS ;
Expand Down Expand Up @@ -211,7 +211,6 @@ TProtease::TProtease ( const wxString& _name , const wxString& m , const wxStrin
}



bool TProtease::does_match ( const wxString& s ) const
{
if ( s.length() != len() ) return false ;
Expand Down
25 changes: 6 additions & 19 deletions TRestrictionIdentifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,24 @@ void TRestrictionIdentifier::initme ()
{
TVirtualGel::initme () ;

wxBoxSizer *main = new wxBoxSizer ( wxHORIZONTAL ) ;
wxBoxSizer *h1 = new wxBoxSizer ( wxHORIZONTAL ) ;
wxBoxSizer *h2 = new wxBoxSizer ( wxHORIZONTAL ) ;
// wxBoxSizer *h3 = new wxBoxSizer ( wxHORIZONTAL ) ;
wxBoxSizer *v = new wxBoxSizer ( wxVERTICAL ) ;

dna_list = new wxCheckListBox ( this , RI_DNA_LIST ) ;
bp_list = new wxChoice ( this , RI_MIN_BP ) ;
percent_list = new wxChoice ( this , RI_MIN_PERCENT ) ;
group_list = new wxChoice ( this , RI_GROUP ) ;
enzymes_list = new wxListBox ( this , RI_ENZYMES_LIST ) ;

wxBoxSizer *h1 = new wxBoxSizer ( wxHORIZONTAL ) ;
h1->Add ( new wxStaticText(this,-1,txt("t_minumum")+" ") , 0 , wxEXPAND , 2 ) ;
h1->Add ( bp_list , 0 , wxEXPAND , 2 ) ;
h1->Add ( new wxStaticText(this,-1,txt("t_bp")) , 0 , wxEXPAND , 2 ) ;

wxBoxSizer *h2 = new wxBoxSizer ( wxHORIZONTAL ) ;
h2->Add ( new wxStaticText(this,-1,txt("t_minumum")+" ") , 0 , wxEXPAND , 2 ) ;
h2->Add ( percent_list , 0 , wxEXPAND , 2 ) ;
h2->Add ( new wxStaticText(this,-1,_T("%")) , 0 , wxEXPAND , 2 ) ;

// wxBoxSizer *h3 = new wxBoxSizer ( wxHORIZONTAL ) ;
// h3->Add ( new wxStaticText(this,-1,txt("enzyme_groups")+_T(" ")) , 0 , wxEXPAND , 2 ) ;
// h3->Add ( group_list , 0 , wxEXPAND , 2 ) ;

Expand All @@ -87,16 +85,6 @@ void TRestrictionIdentifier::initme ()
v->Add ( enzymes_list , 2 , wxEXPAND , 2 ) ;
v->Add ( dna_list , 1 , wxEXPAND , 2 ) ;

main->Add ( v , 0 , wxEXPAND , 2 ) ;
//main->Add ( virtualGel , 1 , wxEXPAND , 2 ) ;
main->Add ( right , 1 , wxEXPAND , 2 ) ;


wxBoxSizer *vs = new wxBoxSizer (wxVERTICAL) ;
vs->Add ( toolbar , 1 , wxEXPAND , 2 ) ;
vs->Add ( main , 1 , wxEXPAND , 2 ) ;


// Init bp/% lists
for ( int a = 0 ; a < 51 ; a++ )
{
Expand Down Expand Up @@ -164,7 +152,6 @@ wxArrayInt TRestrictionIdentifier::getRestrictionFragments ( const wxString& en
v->getCuts ( e , x ) ;
if ( x.size() == 0 ) return ret ; // Empty


int last = 0;
int len = v->getSequenceLength() ;
if ( v->isCircular() )
Expand All @@ -189,7 +176,7 @@ wxArrayInt TRestrictionIdentifier::getRestrictionFragments ( const wxString& en
return ret ;
}

void TRestrictionIdentifier::addRestrictionLane ( const wxString& en , const TVector * const v )
void TRestrictionIdentifier::addRestrictionLane ( const wxString& en , const TVector * const v ) /* not const */
{
wxArrayInt ai = getRestrictionFragments ( en , v ) ;
TGelLane l ;
Expand All @@ -199,11 +186,11 @@ void TRestrictionIdentifier::addRestrictionLane ( const wxString& en , const TVe
l.add ( ai[a] , 100 ) ;
}
l.name = v->getName() ;
lanes.push_back ( l ) ;
lanes.push_back ( l ) ; // not const
}


void TRestrictionIdentifier::recalcEnzymes()
void TRestrictionIdentifier::recalcEnzymes() /* not const */
{
wxArrayString enzyme_names ;
myapp()->frame->LS->getEnzymesInGroup ( group_list->GetStringSelection() , enzyme_names ) ;
Expand Down
56 changes: 39 additions & 17 deletions TVirtualGel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ TVirtualGel::TVirtualGel(wxWindow *parent, const wxString& title)

void TVirtualGel::initme ()
{

wxPrintf("TVirtualGel::initme() - for %s\n", getName()) ;

// Menus
wxMenu *file_menu = myapp()->frame->getFileMenu () ;
wxMenu *tool_menu = myapp()->frame->getToolMenu () ;
Expand All @@ -80,9 +83,6 @@ void TVirtualGel::initme ()

SetMenuBar(menu_bar);

right = new TMyGelControl ( this , IV_IMAGE ) ;
right->vg = this ;

wxToolBar *toolBar = CreateToolBar(wxTB_HORIZONTAL);

//wxBoxSizer *hs = new wxBoxSizer ( wxHORIZONTAL ) ;
Expand All @@ -109,6 +109,16 @@ void TVirtualGel::initme ()

toolbar = toolBar ;

v = new wxBoxSizer ( wxVERTICAL ) ;
main = new wxBoxSizer ( wxHORIZONTAL ) ;

// used in TRestrictionIdentifier
main->Add ( v , 0 , wxEXPAND , 2 ) ;

// vs provided from TVirtualGel
vs = new wxBoxSizer ( wxVERTICAL ) ;
vs->Add ( toolBar , 0 , wxEXPAND , 5 ) ;
vs->Add ( main , 1 , wxEXPAND , 2 ) ;

/*
hs->Add ( cb_label , 0 , wxEXPAND , 5 ) ;
Expand All @@ -118,24 +128,36 @@ void TVirtualGel::initme ()
hs->Add ( ch_marker , 0 , wxEXPAND , 5 ) ;
*/

wxBoxSizer* vs = new wxBoxSizer ( wxVERTICAL ) ;
vs->Add ( toolBar , 0 , wxEXPAND , 5 ) ;
vs->Add ( right , 1 , wxEXPAND , 5 ) ;
right = new TMyGelControl ( this , IV_IMAGE ) ;
right->vg = this ;

if ( getName().IsSameAs ( _T("Restriction Identifier")))
{
wxPrintf("D: TVirtualGel::initme: This is for the display of restriction identifiers\n") ;
main->Add ( right , 1 , wxEXPAND , 5 ) ;
}
else
{
wxPrintf(wxString::Format("D: TVirtualGel::initme: This is for the display of a '%s'\n" , getName() ) ) ;
vs->Add ( right , 1 , wxEXPAND , 5 ) ;
}


myapp()->frame->setChild ( this ) ;

if ( type == _T("DNA") )
{
for ( int a = 3 ; a <= 30 ; a++ )
{
ch_percent->Append ( wxString::Format ( _T("%1.1f %%") , ((float)a)/10.0 ) ) ;
}
ch_percent->SetStringSelection ( _T("1.0 %") ) ;

for ( int a = 0 ; a < myapp()->frame->dna_marker.GetCount() ; a++ )
{
ch_marker->Append ( myapp()->frame->dna_marker[a].BeforeFirst(':') ) ;
}


wxString mbf = _T("??") ;
if ( myapp()->frame && ( myapp()->frame->dna_marker.size() > 0 ) )
{
Expand All @@ -146,9 +168,8 @@ void TVirtualGel::initme ()
lanes.push_back ( TGelLane() ) ;
lanes[0].setMarker ( ch_marker->GetStringSelection() ) ;
}

SetSizer(vs);
// SetSizerAndFit(vs);

SetSizerAndFit ( vs ) ;
Show () ;
Activate () ;

Expand Down Expand Up @@ -382,12 +403,12 @@ void TMyGelControl::OnEvent(wxMouseEvent& event)
if ( event.LeftDClick() )
{
wxPoint p = event.GetPosition() ;
int a ;
for ( a = 0 ; a < vg->lanes.size() ; a++ )
int a = 0 ;
while ( a < vg->lanes.size() )
{
if ( vg->lanes[a].pos.GetLeft() > p.x ) continue ;
if ( vg->lanes[a].pos.GetRight() < p.x ) continue ;
break ;
if ( vg->lanes[a].pos.GetLeft() <= p.x ) break ;
if ( vg->lanes[a].pos.GetRight() >= p.x ) break ;
a++ ;
}
if ( a == vg->lanes.size() ) return ;
// if ( vg->lanes[a].type != "DNA" ) return ;
Expand Down Expand Up @@ -471,11 +492,12 @@ void TGelLane::clear ()

void TGelLane::setMarker ( const wxString& _name )
{
int a ;
for ( a = 0 ; a < myapp()->frame->dna_marker.GetCount() ; a++ )
int a = 0 ;
while ( a < myapp()->frame->dna_marker.GetCount() )
{
if ( myapp()->frame->dna_marker[a].BeforeFirst(':') == _name )
break ;
a++ ;
}
if ( a == myapp()->frame->dna_marker.GetCount() ) return ; // Invalid marker name

Expand Down
5 changes: 5 additions & 0 deletions TVirtualGel.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class TVirtualGel : public ChildBase
int cutoff , maxband ;

DECLARE_EVENT_TABLE()

protected:
wxBoxSizer* vs ; //
wxBoxSizer* v ; //
wxBoxSizer* main ; //
} ;

/** \class TMyGelControl
Expand Down

0 comments on commit 9e8dab4

Please sign in to comment.