code: def read_external_annotation(fn):
      
      assert os.path.exists(fn)
      extDF = pd.read_table(fn, index_col=0, header=0)
      total_num = extDF.shape[0]
      
      # In rare cases, a splice junction might be used by more than one gene. For
      # my purposes, these cases are confounding, so I will remove all such splice
      # junctions. 
      intron_count = extDF.intron.value_counts()
      extDF['intron_count'] = extDF.intron.apply(lambda x: intron_count.ix[x])
      extDF = extDF[extDF.intron_count == 1]
      extDF = extDF.drop('intron_count', axis=1)
  
      stats = []
      stats.append('External database stats')
      stats.append('Read external annotation\t{}'.format(fn))
      stats.append('Total number of junctions\t{:,}'.format(total_num))
      stats.append(('Number of junctions used in only one '
                    'gene\t{:,}').format(extDF.shape[0]))
  
      return extDF, stats
docs: Read file with junctions from some database. This does not have to be the
      same splice junction database used with STAR.
  
      Parameters
      ----------
      fn : filename str
          File with splice junctions from annotation. The file should have a
          header and contain the following columns: 'gene', 'chrom', 'start',
          'end', 'strand', 'chrom:start', 'chrom:end', 'donor', 'acceptor', 
          'intron'.
  
      Returns
      -------
      extDF : pandas.DataFrame
          DataFrame indexed by splice junction
  
      stats : list of strings
          Human readable statistics about the external database.