title: Calling methods using parent class
body: <p>I'm very new to object-oriented programing, and I'm having trouble wrapping my head around how to manage the relationship between classes that have related data.</p>
  
  <p>I'm trying to represent some genomic information about a series of organisms, which I am eventually going to compare. So I have a <code>Species</code> class:</p>
  
  <pre><code>class Species(object):
      def __init__(self, species_name, genes={}, contigs={}):
          self.species_name = species_name
          self.genes = genes
          self.contigs = contigs
  </code></pre>
  
  <p>Then I'd like to have a <code>Gene</code> class,</p>
  
  <pre><code>class Gene(object):
      def __init__(self, locus_tag, annotation, dna_seq, aa_seq):
          self.locus_tag = locus_tag
          self.annotation = annotation
          self.dna_seq = dna_seq
          self.aa_seq = aa_seq
  </code></pre>
  
  <p>The idea is that the <code>genes</code> method of <code>Species</code> will be a dictionary of <code>Gene</code> objects, where the key is the <code>locus_tag</code> of the <code>Gene</code>. I think I know how to implement this part. </p>
  
  <p>But one of the things I'd like to be able to do is call a function on a <code>Gene</code> object that requires knowing what <code>Species</code> it's in (it would output a file structure that includes the <code>species_name</code> and <code>locus_tag</code>, but these are coming from two different classes. The easiest thing I can think of would be to add a <code>species_name</code> directly to the <code>Gene</code> class, but since each <code>Gene</code> will be within a <code>Species</code>, this seems redundant. </p>
  
  <p>I'm not even sure where to begin - I did quite a bit of searching, but the other questions I've found are either not relevant, or I don't understand enough to grasp the relevance.</p>