code: def create_psm_lookup(fn, fastafn, mapfn, header, pgdb, unroll=False,
                        specfncol=None, decoy=False,
                        fastadelim=None, genefield=None):
      
      proteins = store_proteins_descriptions(pgdb, fastafn, fn, mapfn, header,
                                             decoy, fastadelim, genefield)
      mzmlmap = pgdb.get_mzmlfile_map()
      sequences = {}
      for psm in tsvreader.generate_tsv_psms(fn, header):
          seq = tsvreader.get_psm_sequence(psm, unroll)
          sequences[seq] = 1
      pgdb.store_pepseqs(((seq,) for seq in sequences))
      pepseqmap = pgdb.get_peptide_seq_map()
      psms = []
      for row, psm in enumerate(tsvreader.generate_tsv_psms(fn, header)):
          specfn, psm_id, scan, seq, score = tsvreader.get_psm(psm, unroll,
                                                               specfncol)
          if len(psms) % DB_STORE_CHUNK == 0:
              pgdb.store_psms(psms)
              psms = []
          psms.append({'rownr': row,
                       'psm_id': psm_id,
                       'seq': pepseqmap[seq],
                       'score': score,
                       'specfn': mzmlmap[specfn],
                       'scannr': scan,
                       'spec_id': '{}_{}'.format(mzmlmap[specfn], scan),
                       })
      pgdb.store_psms(psms)
      pgdb.index_psms()
      store_psm_protein_relations(fn, header, pgdb, proteins)
docs: Reads PSMs from file, stores them to a database backend in chunked PSMs.