Python Programming for Biology: Bioinformatics and Beyond


Figure 7.1.  The definition of an abstract class and the use of objects made with the



Download 7,75 Mb.
Pdf ko'rish
bet89/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   85   86   87   88   89   90   91   92   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Figure 7.1.  The definition of an abstract class and the use of objects made with the

class. A class definition is an abstract prototype that contains the specification for creating

a custom kind of object data structure. The class is a container for various named values,

which may be simple attributes or functions, which will then belong to any object created

using the class definition. The initialisation function ‘__init__()’ will be called whenever a

new object is made, and this can accept arguments and set the initial state of the object.

After the class specification has been defined, a particular instance can be created using

the class name. Such an object is generally associated with a variable name so that it may

be referred to later, including so that methods (functions bound to the object) can be called

using the dot notation.

Another principle of object-oriented programming is that, in general, a class should be

capable  of  being  extended  by  you,  or  someone  else,  through  the  introduction  of  what  is

known as a subclass. In essence, the subclass inherits all the functionality of the original




class (which is called its superclass) and then adds something extra. To continue the above

example,  someone  might  decide  to  extend  the  Molecule  class  by  introducing  a  subclass

called Protein, which has an extra function getSequence() that returns the sequence of the

protein. Because of the inheritance from the Molecule superclass, the Protein class still has

the function getName() available to it.

Classes  can  have  links  to  other  classes,  aside  from  any  subclass-superclass  hierarchy.

For  example,  the  Protein  class  might  have  a  link  to  a  quite  different  class  called

AminoAcid that models the amino acid residues that make up the protein molecule. Often

when  linking  different  classes  it  is  common  to  provide  functionality  that  allows  you  to

interrogate the links between objects. Accordingly, the Protein class could have a function

getAminoAcids() that returns a list of objects, each of which would be an AminoAcid. If

the  Protein  class  is  used  to  make  an  actual  object  named  myProtein,  then  calling  the

function on this object will give back specific objects that describe its component residues.

The  superclass-subclass  mechanism  can  generally  be  thought  of  as  an  ‘is  a’

relationship,  whereas  the  links  between  classes  can  generally  be  thought  of  as  ‘has  a’  or

‘has’  relationships.  So,  a  Protein  ‘is  a’  Molecule,  whereas  a  Protein  ‘has’  AminoAcid

residues.


Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   85   86   87   88   89   90   91   92   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish