Through scripting, we need to "assemble" if you will, our movie to be rendered. So in case #1, the movie should be segments 1, 2, and 3, in case #2, the movie is segments 1 and 3. In either case, the output is my_movie.mp4. What are ideas on how to do this? Our production process requires that this be done from scripting, so we don't have to open up a project and do it manually.
Would we do it "additive" where we create a new comp and populate it with existing comps, and then it gets rendered so that they play sequentially? Is this possible?
Or should it be more "subtractive" where we have a big comp, (perhaps with segments on different layers), and we turn some layers off, and then squash the timeline to remove empty frames? I'm just guessing here, I'm open to other ideas. Any help appreciated!
Best is additive - far easier to script, say, "add timeline with suffix  and butt up timeline with suffix  and add to render queue"
I would strongly consider rendering uncompressed or an intermediate codec from After Effects. Adobe itself doesn't recommend rendering interframe codecs (assuming MP4 means an mpeg2, mpeg4, or h.264 codec) directly from AE as the process is slower and quality is lower.