<PAGE>

                                                                 EXHIBIT 10.9(B)
 
          AMENDMENT NO. 2 TO RESEARCH, LICENSE AND ROYALTY AGREEMENT


     This Amendment No. 2 to Research, License and Royalty Agreement (the 
"Amendment") effective as of June 30, 1997, is entered into by and between 
Pharmacopeia, Inc. ("Pharmacopeia") and Berlex Laboratories, Inc. ("Berlex"), 
and amends that certain Research, License and Royalty Agreement entered into by
Pharmacopeia and Berlex effective as of February 15, 1995 (the "Agreement"), as 
amended by Amendment No. 1 to Research, License and Royalty Agreement effective 
as of November 27, 1996.

1.   All capitalized terms not defined in this Agreement shall have the meanings
     given to them in the Agreement.

2.   Section 1.3 is amended to read in its entirety as follows:

     1.3   "Additional Berlex Target" shall mean [***].

3.   Section 1.17 is amended to read in its entirety as follows:

     1.17  "Field" means the use for the prevention, mitigation, or cure of 
     diseases of any substance which [***].

4.   Section 1.36 is amended to read in its entirety as follows:

     1.36  "Other Product" means any drug with activity with respect to the
     Initial Berlex Target approved for human or animal use that is not a
     Product (i.e., not based on a Development Compound accepted as an Accepted
     Development Compound in accordance with Section 6.1(b)) and is within the
     scope of a Live Claim. It is understood that a drug meeting the criteria of
     the preceding sentence and that also has biological activity outside the
     Field (i.e. via a different mechanism of action) shall be an Other Product
     only if such drug has an activity (Ki) in the Field of less than [***].

5.   Section 1.39 is amended to read in its entirety as follows:

     1.39 "Product" means any drug with activity within the Field approved for
     human or animal use based on a Development Compound that has received
     Acceptance in accordance with Section 6.1(b) and is within the scope of a
     Live Claim, or a Derivative thereof. It is understood that a drug meeting
     the criteria of the preceding sentence which also has biological activity
     outside the Field (i.e., via a different mechanism of action) shall be a
     Product.

*Information omitted and filed separately with the Commission under Rule 24b-2.

<PAGE>
 
6.   Section 2.2 is amended to read in its entirety as follows:

     2.2 Number of Scientists. Berlex is making the payments described in
     Section V based on the requirement that Pharmacopeia shall provide an
     average of [***] full-time equivalent ("FTE") research positions.

7.   In Section 3.5, the phrase "Chief Scientific Officer for Pharmacopeia"
     shall be replaced with "Senior Vice President of Drug Discovery for
     Pharmacopeia."

8.   In Section 3.7, the phrase "Chief Scientific Officer for Pharmacopeia" 
     shall be replaced with "Senior Vice President, Chemistry, of Pharmacopeia."

9.   Section 4.8 is amended to read in its entirety as follows:

     4.8  Random Libraries.
          -----------------

          (a)  For a period of [***] under the Research Plan with respect to the
               Initial Berlex Target, Pharmacopeia shall not knowingly screen
               Random Libraries with respect to the Initial Berlex Target, nor
               shall Pharmacopeia knowingly (i) design Random LIbraries for the
               purpose of identifying compounds with activity for the Initial
               Berlex Target, (ii) make such Random Libraries, or (iii) use or
               sell such Random Libraries to Third Parties or, (iv) use any
               structure-function data learned as a result of the research under
               the Research Plan for the purposes of subsections (i)-(iii)
               above.

          (b)  For a period of [***} years from the end of the Term, or in the
               event research under the Research Plan with respect to the
               Additional Berlex Target does not proceed until [***], 
               until[***], Pharmacopeia shall not knowingly screen Random
               Libraries with respect to the Additional Berlex Target, nor shall
               Pharmacopeia knowingly (i) design Random Libraries for the
               purpose of identifying compounds with activity for the Additional
               Berlex Target, (ii) make such Random Libraries, or (iii) use or
               sell such Random Libraries to Third Parties or, (iv) use any
               structure-function data learned as a result of the research under
               the Research Plan for the purposes of subsections (i)-(iii)
               above.

          (c)  It is understood that at any time Pharmacopeia may otherwise make
               and provide Random Libraries to Third Parties who may screen such
               Random Libraries against any targets, including without
               limitation, the Initial Berlex Target and Additional Berlex
               Target without the knowledge of Pharmacopeia.

*Information omitted and filed separately with the Commission under Rule 24b-2.

<PAGE>
 
10.  Section 4.14 is amended to read in its entirety as follows:

     4.14   Commercialization Status.  If Berlex is developing a Product or 
            ------------------------       
            Other Products, for a period from the end of the Term to the First
            Commercial Sale of a Product or Other Product, Berlex shall keep
            Pharmacopeia informed of its development activities with respect to
            Products and Other Products, including without limitation, the
            achievement of the milestones set forth in Section 6.1 and 6.2 and
            the commercialization of Products and Other Products, by semi-
            annually providing Pharmacopeia with a written report stating the
            status of development of each such Product and Other Product. If
            research under the Research Plan with respect to the Additional
            Berlex Target does not proceed until [***] and if, at any time,
            Berlex fails to use diligent efforts to actively develop and
            commercialize any Product having activity with respect to the
            Additional Berlex Target, or does not cure any breach with respect
            to such Product noticed by Pharmacopeia pursuant to Section 14.2(a)
            herein within the time permitted thereunder, thereafter Berlex's
            rights under Sections 4.5 and 4.9 herein shall terminate worldwide
            with respect to such Product, as well as with respect to any Focused
            Libraries, Lead Compounds, and Development Compounds from which such
            Product was developed. However, notwithstanding the preceding
            sentence, Berlex can maintain such rights under Section 4.5 and 4.9
            (i.e., such rights shall not terminate) for successive twelve-month
            periods by paying to Pharmacopeia a license maintenance fee of [***]
            per twelve-month period, payable no later than thirty (30) days
            after the commencement of each such twelve-month period.

11.  Section 5.1 is amended to read in its entirety as follows:

     5.1    Term.
            ---- 

            (a)     Subject to Article XIV and Sections 3.2 and 3.5 (as amended
                    herein), the Term of the research activities under the
                    Research Plan shall extend until [***] from the Effective
                    Date. The Term may be further extended with the written
                    agreement of the Parties.
 
            (b)     Berlex shall, at least [***] prior to the end of the Term,
                    notify Pharmacopeia in writing whether Berlex wishes to
                    negotiate an extension of the Term. Such written notice
                    shall include at least the following information: (i)
                    whether Berlex wishes to continue conducting research in the
                    Field or wishes to conduct research with respect to
                    additional or different targets, (ii) an indentification of
                    any such proposed additional or different targets, (iii) the
                    length of the proposed extended Term, and (iv) the proposed
                    amount of funding for such extending Term.

*Information omitted and filed separately with the Commission under Rule 24b-2





  
<PAGE>
 
               (c)  (i) Berlex shall make a payment to Pharmacopeia, in addition
                    to the payments due under Section 5.2, on or before the last
                    day of the Term (the "Wind-Down Payment"). The amount of the
                    Wind-Down Payment shall be [***]. In the event Berlex fails
                    to provide Pharmacopeia written notice as provided under
                    Section 5.1(b), then the amount of the Wind-Down Payment
                    shall be increased to [***].

     (ii) In exchange for the Wind-Down Payment, Pharmacopeia shall provide such
                    number of FTEs as the Research Committee reasonably agrees,
                    in order to complete certain activities previously commenced
                    pursuant to the Research Plan.

12.  Section 5.2 is amended to read in its entirety as follows:

     5.2  Payment. Subject to the delivery of each quarterly written report from
          -------
     Pharmacopeia to Berlex referred to in Section 3.1 pursuant to the Research
     Plan, Berlex shall pay Pharmacopeia research payments as follows:

          (a)  [***] on the Effective Date.

          (b)  [***] within [***] of the Effective Date. 

          (c)  [***] within [***] of the Effective Date.  

          (d)  [***] within [***] of the Effective Date.  
          
          (e)  [***] within [***] of the Effective Date.  

          (f)  [***] within [***] of the Effective Date.  

          (g)  [***] within [***] of the Effective Date.  

          (h)  [***] within [***] of the Effective Date.  

          (i)  [***] within [***] of the Effective Date.  
          
          (j)  [***] within [***] of the Effective Date.  

          (k)  [***] within [***] of the Effective Date.  
          
          (l)  [***] within [***] of receipt of the final written report on the 
               research done pursuant to the Research Plan.

*Information omitted and filed separately with the Commission under Rule 24b-2.
<PAGE>
 
     All payments made pursuant to this Section 5.2 shall be non-refundable, but
     payments under Section 5.2(k) and (l) may be creditable against the Wind-
     Down Payment [***].

13.  Section 6.1(a)(ii) is amended to read in its entirety as follows:

          (ii) [***] upon the initiation of GLP toxicity studies for each
          Development Compound for which Berlex decides to develop a Separate
          Indication and which is a Distinct Molecule from other Accepted
          Development Compounds; provided, however, that the Milestone Payment
          provided in this Section 6.1(a)(ii) is not due and payable for a given
          Development Compound if (i) with respect to a Development Compound
          having activity against the Additional Berlex Target, research under
          the Research Plan with respect to the Additional Berlex Target has
          proceeded until at least [***], and (ii) with respect to a Development
          Compound having activity against either the Initial Berlex Target or
          the Additional Berlex Target, at least one Accepted Development
          Compound has not been provided to Berlex by Pharmacopeia so as to
          enable Berlex to initiate GLP toxicity studies within [***] from the
          start of research by Pharmacopeia with respect to the applicable
          Berlex target (the "Start Date"). The Start Date will be determined by
          the Research Committee with respect to the Initial Berlex Target and
          the Additional Berlex Target, respectively, and stated in the first
          quarterly research report following such Start Date.

14.  Section 6.1(b) is amended to read in its entirety as follows:

     (b)  Acceptance of Development Compounds. The "Acceptance" of each
          -----------------------------------
          Development Compound to become an "Accepted Development Compound"
          shall be determined by the Research Committee in good faith based on
          criteria set forth in the Research Plan. Notwithstanding the above, in
          the event that research under the Research Plan with respect to the
          Additional Berlex Target does not proceed until [***] or the Research
          Committee no longer exists, then "Acceptance" for a particular
          Development Compound shall be deemed to have occurred on the date when
          Berlex initiates [***] based on the applicable Lead Compound or
          Development Compound.

15   The first nine (9) lines of Section 6.2 (comprising the introductory 
     paragraph thereof) are deleted and replaced with the following:

*Information omitted and filed separately with the Commission under Rule 24b-2.
<PAGE>
 
     6.2  Milestones on Other Products. If Pharmacopeia fails to provide Berlex
          ----------------------------
     a Development Compound having activity against the Initial Berlex Target
     within [***] years of the Start Date, but provides Berlex with a Lead
     Compound within the Term, and Berlex initiates GLP toxicity studies on such
     Lead Compound or a compound Derived therefrom after the Effective Date, and
     such Lead Compound or a compound Derived therefrom becomes an intended
     Other Product or an Other Product, then Berlex shall pay to Pharmacopeia
     Milestone Payments with respect to such Other Product or intended Other
     Product as follows:

16.  Section 6.5 is amended to read in its entirety as follows:

     6.5  No Obligations for Non-Products. It is understood that Berlex is in
          -------------------------------
     the Business of developing products for the prevention, treatment, cure and
     mitigation of diseases in animals and that Berlex has extensive research
     programs independent of Pharmacopeia. Pharmacopeia acknowledges that Berlex
     has no obligations to pay Pharmacopeia royalties for a product in the Field
     which Berlex independently researched, developed and commercialized, either
     alone or in conjunction with Third Parties, without the use of or reliance
     on Developed Technology or Pharmacopeia Base Technology, as shown by
     written records kept in the ordinary course of business consistent with
     pharmaceutical industry standards (a "Non-Product"). Unless, with respect
     to a particular putative Non-Product, Berlex has not initiated GLP
     toxicity studies within the periods set forth in Sections 6.1(a) or 6.2(b)
     if applicable, within thirty (30) days of the filing of an IND with respect
     to each Non-Product for which Berlex believes no royalties and/or Milestone
     Payments are due Pharmacopeia, Berlex shall notify Pharmacopeia of such
     filing, and shall, to the extent it may do so without breaching any
     contractual or other legal obligation, provide Pharmacopeia with a
     statement explaining why Berlex believes the Non-Product was independently,
     researched, developed and commercialized, either alone or in conjunction
     with Third Parties without the use of or reliance on Developed Technology
     or Pharmacopeia Base Technology and is independent of Berlex's activities
     under the Research Plan. Berlex is not required to provide written records
     referred to above at the time providing such statement, but may have to
     provide such records pursuant to Section 15.19. Such Information shall be
     deemed Berlex confidential Information pursuant to this Agreement.

17.  The first ten (10) lines of Section 7.3 (comprising the introductory 
     paragraph thereof) are deleted and replaced with the following:

     7.3  Royalties on Other Products. If Pharmacopeia fails to provide Berlex
          ---------------------------
     an Accepted Development Compound having activity against the Initial Berlex
     Target within [***] years of the Start Date, but provides Berlex with a
     Lead Compound within the Term, and Berlex initiates GLP toxicity studies on
     such Lead Compound or a compound Derived therefrom after the Effective
     Date, and such Lead Compound or a compound Derived

<PAGE>
 
          therefrom becomes an Other Product, then Berlex shall pay to
          Pharmacopeia royalties with respect to such Other Product for a
          Separate Indication and which is a Distinct Molecule from any other
          Products or Other Products, as set forth below:

     18.  Section 14.2 is amended by the deletion of subsection 14.2(d).

     19.  Except as specifically modified or amended hereby, the Agreement shall
          remain in full force and effect and, as modified or amended, is hereby
          ratified, confirmed and approved. No provision of this Amendment may
          be modified or amended except expressly in a writing signed by both
          parties nor shall any terms be waived except expressly in a writing
          signed by the party charged therewith. This Amendment shall be
          governed in accordance with the laws of the State of Delaware, without
          regard to principles of conflicts of laws.

          IN WITNESS WHEREOF, each of the parties has executed this Amendment as
     of the date indicated on this Amendment.

     BERLEX LABORATORIES, INC.                 PHARMACOPEIA, INC.

     By:______________________                 By:_____________________

     Name:____________________                 Name:___________________
          
     Title:___________________                 Title:__________________

     Date:____________________                 Date:___________________