In general western music it’s relatively simple: learn the 12 keys, chords/ chord tones and scales. Best way to practice this is across 12 keys, ascending and descending in different patterns, speeding up when you’re playing the right notes consistently.
Lines are made up of chord tones, passing tones and chromatics, so once you get to grip with the above it’s possible to analyse anything.